Found 17009 results in 553 files, showing top 50 files (show more).
github.com/llvm-mirror/clang:lib/Sema/AnalysisBasedWarnings.cpp: [ master, ]
727:   const DeclRefExpr *Needle;
56:   class UnreachableCodeHandler : public reachable_code::Callback {
125: class LogicalErrorHandler : public CFGCallback {
197:     // Skip function calls which are qualified with a templated class.
722: /// ContainsReference - A visitor class to search for references to
725: class ContainsReference : public ConstEvaluatedExprVisitor<ContainsReference> {
732:   ContainsReference(ASTContext &Context, const DeclRefExpr *Needle)
733:     : Inherited(Context), FoundReference(false), Needle(Needle) {}
744:     if (E == Needle)
1033:   class FallthroughMapper : public RecursiveASTVisitor<FallthroughMapper> {
1500: class UninitValsDiagReporter : public UninitVariablesHandler {
1612: class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
1884: class ConsumedWarningsHandler : public ConsumedWarningsHandlerBase {
258:   // templated classes.
861:     switch (Term ? Term->getStmtClass() : Stmt::DeclStmtClass) {
868:     case Stmt::IfStmtClass: {
878:     case Stmt::ConditionalOperatorClass: {
888:     case Stmt::BinaryOperatorClass: {
908:     case Stmt::WhileStmtClass:
915:     case Stmt::ForStmtClass:
925:     case Stmt::CXXForRangeStmtClass:
938:     case Stmt::DoStmtClass:
947:     case Stmt::CaseStmtClass:
952:     case Stmt::DefaultStmtClass:
1323:     switch (S->getStmtClass()) {
1324:     case Stmt::ForStmtClass:
1325:     case Stmt::WhileStmtClass:
1326:     case Stmt::CXXForRangeStmtClass:
1327:     case Stmt::ObjCForCollectionStmtClass:
1329:     case Stmt::DoStmtClass: {
1417:   // Classify the current code body for better warning text.
1420:   // FIXME: Should we use a common classification enum and the same set of
1455:     // Classify the weak object being accessed for better warning text.
2077:       .setAlwaysAdd(Stmt::BinaryOperatorClass)
2078:       .setAlwaysAdd(Stmt::CompoundAssignOperatorClass)
2079:       .setAlwaysAdd(Stmt::BlockExprClass)
2080:       .setAlwaysAdd(Stmt::CStyleCastExprClass)
2081:       .setAlwaysAdd(Stmt::DeclRefExprClass)
2082:       .setAlwaysAdd(Stmt::ImplicitCastExprClass)
2083:       .setAlwaysAdd(Stmt::UnaryOperatorClass)
2084:       .setAlwaysAdd(Stmt::AttributedStmtClass);
android.googlesource.com/platform/external/clang:lib/Sema/AnalysisBasedWarnings.cpp: [ master, ]
591:   const DeclRefExpr *Needle;
62:   class UnreachableCodeHandler : public reachable_code::Callback {
121: class LogicalErrorHandler : public CFGCallback {
179:     // Skip function calls which are qualified with a templated class.
586: /// ContainsReference - A visitor class to search for references to
589: class ContainsReference : public ConstEvaluatedExprVisitor<ContainsReference> {
596:   ContainsReference(ASTContext &Context, const DeclRefExpr *Needle)
597:     : Inherited(Context), FoundReference(false), Needle(Needle) {}
608:     if (E == Needle)
899:   class FallthroughMapper : public RecursiveASTVisitor<FallthroughMapper> {
1360: class UninitValsDiagReporter : public UninitVariablesHandler {
1472: class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
1742: class ConsumedWarningsHandler : public ConsumedWarningsHandlerBase {
259:   // templated classes.
727:     switch (Term ? Term->getStmtClass() : Stmt::DeclStmtClass) {
734:     case Stmt::IfStmtClass: {
744:     case Stmt::ConditionalOperatorClass: {
754:     case Stmt::BinaryOperatorClass: {
774:     case Stmt::WhileStmtClass:
781:     case Stmt::ForStmtClass:
791:     case Stmt::CXXForRangeStmtClass:
804:     case Stmt::DoStmtClass:
813:     case Stmt::CaseStmtClass:
818:     case Stmt::DefaultStmtClass:
1182:     switch (S->getStmtClass()) {
1183:     case Stmt::ForStmtClass:
1184:     case Stmt::WhileStmtClass:
1185:     case Stmt::CXXForRangeStmtClass:
1186:     case Stmt::ObjCForCollectionStmtClass:
1188:     case Stmt::DoStmtClass: {
1277:   // Classify the current code body for better warning text.
1280:   // FIXME: Should we use a common classification enum and the same set of
1315:     // Classify the weak object being accessed for better warning text.
1935:       .setAlwaysAdd(Stmt::BinaryOperatorClass)
1936:       .setAlwaysAdd(Stmt::CompoundAssignOperatorClass)
1937:       .setAlwaysAdd(Stmt::BlockExprClass)
1938:       .setAlwaysAdd(Stmt::CStyleCastExprClass)
1939:       .setAlwaysAdd(Stmt::DeclRefExprClass)
1940:       .setAlwaysAdd(Stmt::ImplicitCastExprClass)
1941:       .setAlwaysAdd(Stmt::UnaryOperatorClass)
1942:       .setAlwaysAdd(Stmt::AttributedStmtClass);
android.googlesource.com/platform/superproject:external/clang/lib/Sema/AnalysisBasedWarnings.cpp: [ master, ] Duplicate result
chromium.googlesource.com/native_client/pnacl-clang:lib/Sema/AnalysisBasedWarnings.cpp: [ master, ]
579:   const DeclRefExpr *Needle;
63:   class UnreachableCodeHandler : public reachable_code::Callback {
122: class LogicalErrorHandler : public CFGCallback {
203:         // Skip function calls which are qualified with a templated class.
574: /// ContainsReference - A visitor class to search for references to
577: class ContainsReference : public EvaluatedExprVisitor<ContainsReference> {
582:   ContainsReference(ASTContext &Context, const DeclRefExpr *Needle)
584:       FoundReference(false), Needle(Needle) {}
595:     if (E == Needle)
888:   class FallthroughMapper : public RecursiveASTVisitor<FallthroughMapper> {
1325: class UninitValsDiagReporter : public UninitVariablesHandler {
1442: class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
1713: class ConsumedWarningsHandler : public ConsumedWarningsHandlerBase {
240:   // templated classes.
715:     switch (Term ? Term->getStmtClass() : Stmt::DeclStmtClass) {
722:     case Stmt::IfStmtClass: {
732:     case Stmt::ConditionalOperatorClass: {
742:     case Stmt::BinaryOperatorClass: {
762:     case Stmt::WhileStmtClass:
769:     case Stmt::ForStmtClass:
779:     case Stmt::CXXForRangeStmtClass:
792:     case Stmt::DoStmtClass:
801:     case Stmt::CaseStmtClass:
806:     case Stmt::DefaultStmtClass:
1152:     switch (S->getStmtClass()) {
1153:     case Stmt::ForStmtClass:
1154:     case Stmt::WhileStmtClass:
1155:     case Stmt::CXXForRangeStmtClass:
1156:     case Stmt::ObjCForCollectionStmtClass:
1158:     case Stmt::DoStmtClass: {
1248:   // Classify the current code body for better warning text.
1251:   // FIXME: Should we use a common classification enum and the same set of
1286:     // Classify the weak object being accessed for better warning text.
1903:       .setAlwaysAdd(Stmt::BinaryOperatorClass)
1904:       .setAlwaysAdd(Stmt::CompoundAssignOperatorClass)
1905:       .setAlwaysAdd(Stmt::BlockExprClass)
1906:       .setAlwaysAdd(Stmt::CStyleCastExprClass)
1907:       .setAlwaysAdd(Stmt::DeclRefExprClass)
1908:       .setAlwaysAdd(Stmt::ImplicitCastExprClass)
1909:       .setAlwaysAdd(Stmt::UnaryOperatorClass)
1910:       .setAlwaysAdd(Stmt::AttributedStmtClass);
android.googlesource.com/platform/external/clang_35a:lib/Sema/AnalysisBasedWarnings.cpp: [ master, ]
577:   const DeclRefExpr *Needle;
63:   class UnreachableCodeHandler : public reachable_code::Callback {
121: class LogicalErrorHandler : public CFGCallback {
192:         // Skip function calls which are qualified with a templated class.
572: /// ContainsReference - A visitor class to search for references to
575: class ContainsReference : public EvaluatedExprVisitor<ContainsReference> {
580:   ContainsReference(ASTContext &Context, const DeclRefExpr *Needle)
582:       FoundReference(false), Needle(Needle) {}
593:     if (E == Needle)
885:   class FallthroughMapper : public RecursiveASTVisitor<FallthroughMapper> {
1331: class UninitValsDiagReporter : public UninitVariablesHandler {
1454: class ThreadSafetyReporter : public clang::thread_safety::ThreadSafetyHandler {
1629: class ConsumedWarningsHandler : public ConsumedWarningsHandlerBase {
229:   // templated classes.
712:     switch (Term ? Term->getStmtClass() : Stmt::DeclStmtClass) {
719:     case Stmt::IfStmtClass: {
729:     case Stmt::ConditionalOperatorClass: {
739:     case Stmt::BinaryOperatorClass: {
759:     case Stmt::WhileStmtClass:
766:     case Stmt::ForStmtClass:
776:     case Stmt::CXXForRangeStmtClass:
789:     case Stmt::DoStmtClass:
798:     case Stmt::CaseStmtClass:
803:     case Stmt::DefaultStmtClass:
1155:     switch (S->getStmtClass()) {
1156:     case Stmt::ForStmtClass:
1157:     case Stmt::WhileStmtClass:
1158:     case Stmt::CXXForRangeStmtClass:
1159:     case Stmt::ObjCForCollectionStmtClass:
1161:     case Stmt::DoStmtClass: {
1251:   // Classify the current code body for better warning text.
1254:   // FIXME: Should we use a common classification enum and the same set of
1291:     // Classify the weak object being accessed for better warning text.
1831:       .setAlwaysAdd(Stmt::BinaryOperatorClass)
1832:       .setAlwaysAdd(Stmt::CompoundAssignOperatorClass)
1833:       .setAlwaysAdd(Stmt::BlockExprClass)
1834:       .setAlwaysAdd(Stmt::CStyleCastExprClass)
1835:       .setAlwaysAdd(Stmt::DeclRefExprClass)
1836:       .setAlwaysAdd(Stmt::ImplicitCastExprClass)
1837:       .setAlwaysAdd(Stmt::UnaryOperatorClass)
1838:       .setAlwaysAdd(Stmt::AttributedStmtClass);
github.com/google/rekall:rekall-gui/manuskript/static/bower_components/markdown/test/fixtures/Markdown-from-MDTest1.1.mdtest/Markdown_Documentation_-_Syntax.json: [ master, ]
15:         "class": "selected",
264:     ["pre", ["code", "    <div class=\"footer\">\u000a        &copy; 2004 Foo Corporation\u000a    </div>\u000a"]],
266:     ["pre", ["code", "<pre><code>&lt;div class=\"footer\"&gt;\u000a    &amp;copy; 2004 Foo Corporation\u000a&lt;/div&gt;\u000a</code></pre>\u000a"...(3 bytes skipped)...
149:     ["p", "in your anchor tag ", ["code", "href"], " attribute. Needless to say, this is easy to\u000aforget, and is probably the single most common source of HTML valida...(58 bytes skipped)...
chromium.googlesource.com/native_client/nacl-gdb:sim/common/sim-fpu.h: [ master, ]
89: } sim_fpu_class;
83:   sim_fpu_class_zero,
84:   sim_fpu_class_snan,
85:   sim_fpu_class_qnan,
86:   sim_fpu_class_number,
87:   sim_fpu_class_denorm,
88:   sim_fpu_class_infinity,
92:   sim_fpu_class class;
346: /* General number class and comparison operators.
46:    Needless to say the results, while better than for a packed 64 bit
297: /* Specific number classes.
chromium.googlesource.com/native_client/nacl-toolchain:gdb/sim/common/sim-fpu.h: [ master, ]
89: } sim_fpu_class;
83:   sim_fpu_class_zero,
84:   sim_fpu_class_snan,
85:   sim_fpu_class_qnan,
86:   sim_fpu_class_number,
87:   sim_fpu_class_denorm,
88:   sim_fpu_class_infinity,
92:   sim_fpu_class class;
346: /* General number class and comparison operators.
46:    Needless to say the results, while better than for a packed 64 bit
297: /* Specific number classes.
github.com/hanwen/artisjokke:needle2d/needle-inserter.hh: [ master, ]
13: class Needle_inserter : public Deformation_hook
2:   declare Needle_inserter
54:   Needle_inserter (Maubach_tree*, Deformation_state*);
github.com/gwtproject/gwt:samples/dynatable/src/com/google/gwt/sample/dynatable/server/SchoolCalendarServiceImpl.java: [ master, ]
52:   private static final int CLASS_LENGTH_MINS = 50;
34: public class SchoolCalendarServiceImpl extends RemoteServiceServlet implements
146:       int absStopMins = absStartMins + CLASS_LENGTH_MINS;
43:       "Crutcher", "Needler", "Wilson", "Chase", "Edelstein"};
168:     generateRandomSchedule(student.getClassSchedule());
github.com/hanwen/artisjokke:needle3d/needle-inserter3.hh: [ master, ]
10: class Needle_inserter3 : public Deformation_hook,  public Element_watcher
12:   enum Needle_state {
16:   Needle_state state_;
55:   Needle_inserter3 (Maubach_tree3*, Deformation_state*);
gwt.googlesource.com/gwt:samples/dynatable/src/com/google/gwt/sample/dynatable/server/SchoolCalendarServiceImpl.java: [ master, ] Duplicate result
chromium.googlesource.com/chromium/deps/perl:perl/lib/pods/perlobj.pod: [ master, ]
600: =head3 Class Names as Strings
772: =head2 The UNIVERSAL Class
168: =head2 A Class is Simply a Package
655: =head2 Invoking Class Methods
36: An object is simply a data structure that knows to which class it
41: A class is simply a package. A class provides methods that expect to
47: (or a package name, for class methods) as the first argument.
59: etc.) that have been explicitly associated with a particular class.
63: class.
70:       my $class = shift;
72:       return bless {}, $class;
81:       my $class = shift;
83:       return bless {}, $class;
88: subroutine that blesses a data structure into a class is a valid
93: and associates the hash with the class in C<$class>. In the simplest
94: case, the C<$class> variable will end up containing the string "File".
100:       my $class = shift;
103:       bless $self, $class;
113:       my $class = shift;
116:       bless $self, $class;
124: store data associated with the object. Typically, code inside the class
126: the class should always treat the object as opaque. This is called
150:   bless $foo, 'Class';
151:   print blessed( $bar );      # prints "Class"
169: X<class> X<package> X<@ISA> X<inheritance>
171: Perl does not provide any special syntax for class definitions. A
173: only difference is that in a class, the subroutines may expect a
174: reference to an object or the name of a class as the first argument.
175: This is purely a matter of convention, so a class may contain both
176: methods and subroutines which I<don't> operate on an object or class.
179: contains a list of that class's parent classes, if any. This array is
193: All classes inherit from the L<UNIVERSAL> class implicitly. The
194: L<UNIVERSAL> class is implemented by the Perl core, and provides
196: The C<UNIVERSAL> class will I<never> appear in a package's C<@ISA>
200: Attribute inheritance is left up the class to implement. See the
209: object or a class name as its first argument.
230: object (or class name), and the right hand side is the method name.
266: When a class inherits from another class, any methods defined in the
267: parent class are available to the child class. If you attempt to call a
268: method on an object that isn't defined in its own class, Perl will also
277: Since we didn't define a C<save()> method in the C<File::MP3> class,
278: Perl will look at the C<File::MP3> class's parent classes to find the
282: In this case, it finds a C<save()> method in the C<File> class. Note
285: class.
287: We can override a parent's method in a child class. When we do so, we
288: can still call the parent class's method with the C<SUPER>
289: pseudo-class.
299: use it for regular subroutine calls or class methods:
303:   SUPER->save($thing);     # FAIL: looks for save() method in class
313: The C<SUPER> pseudo-class is resolved from the package where the call
314: is made. It is I<not> resolved based on the object's class. This is
367: blessed into the C<C> class, the C<speak()> method in the C<B> class
369: parent class of C<B> (i.e the class the method call is in), not in the
370: parent class of C<C> (i.e. the class the object belongs to).
382: To declare multiple parents, you simply need to pass multiple class
403: in the C<Child> class, Perl will look for that method in the C<Parent>
404: class and then, if necessary, in the C<Grandparent> class.
409: When a class has multiple parents, the method lookup order becomes more
416: class's C<@ISA> array and searches from there.
451: C<next> pseudo-class. See the L<mro> documentation for more details on
458: class's parent class or adding subroutines to a class will invalidate
459: the cache for that class.
468: This means that a class must implement its own constructor. A
469: constructor is simply a class method that returns a reference to a new
473: object. Let's write a real constructor for the C<File> class we used
479:       my $class = shift;
485:       }, $class;
494: For our File::MP3 class, we can check to make sure that the path we're
500:       my $class = shift;
506:       return $class->SUPER::new(@_);
509: This constructor lets its parent class do the actual object
524: class, it's considered a best practice to wrap all access to the
537: use the accessors rather than having to know how a parent class is
602: Perl also lets you use a scalar containing a string as a class name:
604:   my $class = 'File';
606:   my $file = $class->new( $path, $data );
645: C<IO::File> class. Once you have an open filehandle, you can call
660: incorrectly. For example, the construct C<< Class->new() >> can be
661: interpreted as either C<< 'Class'->new() >> or C<< Class()->new() >>.
663: named Class(), then call new() as a method on the return value of
664: Class()". If there is a subroutine named C<Class()> in the current
665: namespace, Perl will always interpret C<< Class->new() >> as the second
667: C<Class()>
670: call on the class named "Class") in two ways. First, you can append a
671: C<::> to the class name:
673:     Class::->new()
677: Alternatively, you can quote the class name:
679:     'Class'->new()
681: Of course, if the class name is in a scalar Perl will do the right
684:     my $class = 'Class';
685:     $class->new();
697: This syntax can be used with any class or object method:
705: clear if C<save> is a method provided by the C<File> class or simply a
708: When used with class methods, the problem is even worse. Because Perl
710: whether the bareword after the method is a class name or subroutine
723: You can force Perl to interpret the bareword as a class name by
731: blessed into a class via the C<bless> function. The C<bless> function
734:   my $object = bless {}, $class;
737: In the first form, the anonymous hash is being blessed into the class
738: in C<$class>. In the second form, the anonymous hash is blessed into
759: been blessed into a class named "0". This is a possible, but quite
760: pathological. Don't create a class named "0" unless you know what
765: holds a reference to an object, it will return the name of the class
775: All classes automatically inherit from the L<UNIVERSAL> class, which is
776: built-in to the Perl core. This class provides a number of methods, all
777: of which can be called on either a class or an object. You can also
778: choose to override some of these methods in your class. If you do so,
783: =item isa($class)
787: class in C<$class>, or a member of a subclass of C<$class>.
805: The C<can> method checks to see if the class or object it was called on
806: has a method named C<$method>. This checks for the method in the class
810: If your class responds to method calls via C<AUTOLOAD>, you may want to
819: The C<VERSION> method returns the version number of the class
845: If you call a method that doesn't exist in a class, Perl will throw an
846: error. However, if that class or any of its parent classes defines an
854: C<$AUTOLOAD> package global for your class. Since this is a global, if
885: If your class does have an C<AUTOLOAD> method, we strongly recommend
886: that you override C<can> in your class as well. Your overridden C<can>
900: define a C<DESTROY> method in your class. This method will always be
918: If you define an C<AUTOLOAD> in your class, then Perl will call your
975:       my $class = shift;
978:       return bless \$time, $class;
1018:       my $class = shift;
1020:       my $self = bless \( my $object ), $class;
186: parent classes and make sure that the package doesn't inherit from
189: However the parent classes are set, the package's C<@ISA> variable will
269: look for that method in any parent classes it may have.
307:                            #       classes
406: If Perl cannot find the method in any of these classes, it will die
430: derived classes (i.e. before we tried C<Mother> and
442: terms, "C3" order ensures that shared parent classes are never searched
443: before child classes, so Perl will now search: C<Child>, C<Father>,
450: The C3 order also lets you call methods in sibling classes with the
544: syntax, so classes must provide explicitly written accessor methods.
716: barewords it has previously seen, and other input. Needless to say,
742: of a subclass to reuse the parent's constructor, but you may still run
799: You can also override C<DOES> directly in your own classes. If you
1048: some style guides on constructing both modules and classes.
536: Finally, using accessors makes inheritance much simpler. Subclasses can
kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux:drivers/char/xillybus/xillybus_core.c: [ master, ]
61: static struct class *xillybus_class;
1843: 		device = device_create(xillybus_class,
1865: 		device_destroy(xillybus_class, MKDEV(major, i));
1881: 		device_destroy(xillybus_class, MKDEV(endpoint->major, minor));
2082: 	xillybus_class = class_create(THIS_MODULE, xillyname);
2083: 	if (IS_ERR(xillybus_class))
2084: 		return PTR_ERR(xillybus_class);
2088: 		class_destroy(xillybus_class);
2100: 	class_destroy(xillybus_class);
81:  * They are held for short direct memory manipulations. Needless to say,
github.com/google/kmsan:drivers/char/xillybus/xillybus_core.c: [ master, ] Duplicate result
github.com/google/capsicum-linux:drivers/char/xillybus/xillybus_core.c: [ capsicum, ]
64: static struct class *xillybus_class;
1846: 		device = device_create(xillybus_class,
1868: 		device_destroy(xillybus_class, MKDEV(major, i));
1884: 		device_destroy(xillybus_class, MKDEV(endpoint->major, minor));
2085: 	xillybus_class = class_create(THIS_MODULE, xillyname);
2086: 	if (IS_ERR(xillybus_class))
2087: 		return PTR_ERR(xillybus_class);
2091: 		class_destroy(xillybus_class);
2103: 	class_destroy(xillybus_class);
84:  * They are held for short direct memory manipulations. Needless to say,
github.com/google/ktsan:drivers/char/xillybus/xillybus_core.c: [ tsan, ]
64: static struct class *xillybus_class;
1844: 		device = device_create(xillybus_class,
1866: 		device_destroy(xillybus_class, MKDEV(major, i));
1882: 		device_destroy(xillybus_class, MKDEV(endpoint->major, minor));
2083: 	xillybus_class = class_create(THIS_MODULE, xillyname);
2084: 	if (IS_ERR(xillybus_class))
2085: 		return PTR_ERR(xillybus_class);
2089: 		class_destroy(xillybus_class);
2101: 	class_destroy(xillybus_class);
84:  * They are held for short direct memory manipulations. Needless to say,
github.com/google/pytype:googletest/googlemock/docs/CookBook.md: [ master, ]
556: ## Delegating Calls to a Parent Class ##
94: ## Mocking Class Templates ##
13: # Creating Mock Classes #
352: ## Alternative to Mocking Concrete Classes ##
18: `public:` section of the mock class, regardless of the method being
19: mocked being `public`, `protected`, or `private` in the base class.
21: from outside of the mock class.  (Yes, C++ allows a subclass to specify
22: a different access level than the base class on a virtual function.)
26: class Foo {
38: class MockFoo : public Foo {
44:   // methods are protected or private in the base class.
55: class Foo {
70: class MockFoo : public Foo {
81: compiler will give you a warning about some methods in the base class
85: class MockFoo : public Foo {
96: To mock a class template, append `_T` to the `MOCK_*` macros:
100: class StackInterface {
110: class MockStack : public StackInterface<Elem> {
122: In this case, instead of sharing a common base class with the real
123: class, your mock class will be _unrelated_ to the real class, but
128: // A simple packet stream class.  None of its members is virtual.
129: class ConcretePacketStream {
137: // A mock packet stream class.  It inherits from no other, but defines
139: class MockPacketStream {
147: Note that the mock class doesn't define `AppendPacket()`, unlike the
148: real class. That's fine as long as the test doesn't need to call it.
164: template <class PacketStream>
167: template <class PacketStream>
168: class PacketReader {
191: code to use an interface (abstract class).
198: class FileInterface {
204: class File : public FileInterface {
237: Suppose your test uses a mock class `MockFoo`:
297: ...(58 bytes skipped)...rk for mock methods defined using the `MOCK_METHOD*` family of macros **directly** in the `MockFoo` class. If a mock method is defined in a **base class** of `MockFoo`, the "nice" or "strict" modifier may not affect it, depending on the compiler. In pa...(107 bytes skipped)...
299: ...(298 bytes skipped)...irtual method of `this` object, that method is treated as non-virtual.  In other words, to the base class's constructor or destructor, `this` object behaves like an instance of the base class, not the derived class.  This rule is required for safety.  Otherwise a base constructor may use members of a derived class before they are initialized, or a base destructor may use members of a derived class after they have been destroyed.)
309: class LogSink {
325: The trick is to re-dispatch the method in the mock class:
328: class ScopedMockLog : public LogSink {
350: the mock class much more user-friendly.
355: interfaces. In order to test your code that uses such a class (let's
362: extension point where subclasses can tweak your class' behavior. This
363: weakens your control on the class because now it's harder to maintain
364: the class' invariants. You should make a function virtual only when
368: coupling between the class and the tests - any small change in the
369: class may invalidate your tests and make test maintenance a pain.
372: to interfaces": instead of talking to the `Concrete` class, your code
385: ...(185 bytes skipped)...our need - you may add higher-level functionalities, rename stuff, etc instead of just trimming the class. This allows you to write your code (user of the interface) in a more natural way, which means it w...(71 bytes skipped)...
407: class Foo {
414: class FakeFoo : public Foo {
432: When you define the mock class using Google Mock, you can have it
433: delegate its default action to a fake class you already have, using
440: class MockFoo : public Foo {
487: ...(336 bytes skipped)... you place inside `Invoke()`), use a `static_cast` to specify the function's type. For instance, if class `Foo` has methods `char DoThis(int n)` and `bool DoThis(double x) const`, and you want to invoke th...(294 bytes skipped)...
491: why it may be a bad sign: Suppose you have a class `System` for
495: you mock out the entire `System` class, you'll have to provide a fake
523: class MockFoo : public Foo {
563: class Foo {
571: class MockFoo : public Foo {
583: (but it would be oh-so painful to have to define a new mock class
586: The trick is to leave a back door in your mock class for accessing the
587: real methods in the base class:
590: class MockFoo : public Foo {
716: // A base class and a child class.
717: class Base { ... };
718: class Derived : public Base { ... };
720: class MockFoo : public Foo {
750: class MockFoo : public Foo {
780: class MockPrinter : public Printer {
1109: class BarPlusBazEqMatcher : public MatcherInterface<const Foo&> {
1314: In Google Mock, `NiceMock` and `StrictMock` can be used to make a mock class "nice" or "strict". How does this affect uninteresting calls and unexpected calls?
1395: `InSequence` class), which we borrowed from jMock 2. It's less
1507: class MockFoo : public Foo {
1538: class MockFoo : public Foo {
1591: class MockFoo : public Foo {
1617: class MockMutator : public Mutator {
1646: class MockMutator : public Mutator {
1668: class MockArrayMutator : public ArrayMutator {
1687: class MockRolodex : public Rolodex {
1754: about. You can do this using the `::testing::DefaultValue` class
1758: class MockFoo : public Foo {
1830: class MockFoo : public Foo {
1838: class Helper {
1885: class MockFoo : public Foo {
1906: class MockFoo : public Foo {
2012: class MockFoo : public Foo {
2246: enum class AccessLevel { kInternal, kPublic };
2248: class Buzz {
2254: class Buzzer {
2263: A `Buzz` object represents a snippet being posted. A class that implements the
2272: class MockBuzzer : public Buzzer {
2279: Now that we have the mock class defined, we can use it in tests. In the
2377: class MockBuzzer : public Buzzer {
2406: a mock class is in generating its constructor and destructor, as they
2411: different types of methods, compiling your mock class can get really
2415: of your mock class' constructor and destructor out of the class body
2417: class in N files, the compiler only needs to generate its constructor
2421: mock class before applying this recipe:
2426: class MockFoo : public Foo {
2430:   // where this mock class is used.
2443: class MockFoo : public Foo {
2554:   // Class MockFunction<F> has exactly one mock method.  It is named
2596: effect. First, add a mock function `Die()` to your mock class and call
2600: class MockFoo : public Foo {
2602:   // Add the following two lines to the mock class.
2745: class MockFoo {
3062: class MatchResultListener {
3075: class MatcherInterface {
3107: class DivisibleBy7Matcher : public MatcherInterface<int> {
3134: class DivisibleBy7Matcher : public MatcherInterface<int> {
3176: class NotNullMatcher {
3178:   // To implement a polymorphic matcher, first define a COPYABLE class
3199: // To construct a polymorphic matcher, pass an instance of the class
3209: **Note:** Your polymorphic matcher class does **not** need to inherit from
3210: `MatcherInterface` or any other class, and its methods do **not** need
3228: class CardinalityInterface {
3251: class EvenNumberCardinality : public CardinalityInterface {
3286: in a namespace scope (i.e. not inside a class or function), you will
3526: template <typename F>class ActionInterface {
3545: class IncrementArgumentAction : public ActionInterface<IncrementMethod> {
3588: implementation class:
3591: class ReturnSecondArgumentAction {
3601: This implementation class does _not_ need to inherit from any
3602: particular class. What matters is that it must have a `Perform()`
3611: implementation class into the polymorphic action we need. It will be
3629: class MockFoo : public Foo {
152: in tests.  Since the functions are not virtual and the two classes are
194: introduce an interface for it and have a concrete subclass that calls
262: `NiceMock<MockFoo>` is a subclass of `MockFoo`, so it can be used
354: Often you may find yourself using classes that don't implement
365: there is a valid reason for a subclass to override it.
367: Mocking concrete classes directly is problematic as it creates a tight
1874: invoking an underlining nullary function. Needless to say, this can be
skia.googlesource.com/external/github.com/Tencent/rapidjson:thirdparty/gtest/googlemock/docs/CookBook.md: [ master, ]
556: ## Delegating Calls to a Parent Class ##
94: ## Mocking Class Templates ##
13: # Creating Mock Classes #
352: ## Alternative to Mocking Concrete Classes ##
18: `public:` section of the mock class, regardless of the method being
19: mocked being `public`, `protected`, or `private` in the base class.
21: from outside of the mock class.  (Yes, C++ allows a subclass to specify
22: a different access level than the base class on a virtual function.)
26: class Foo {
38: class MockFoo : public Foo {
44:   // methods are protected or private in the base class.
55: class Foo {
70: class MockFoo : public Foo {
81: compiler will give you a warning about some methods in the base class
85: class MockFoo : public Foo {
96: To mock a class template, append `_T` to the `MOCK_*` macros:
100: class StackInterface {
110: class MockStack : public StackInterface<Elem> {
122: In this case, instead of sharing a common base class with the real
123: class, your mock class will be _unrelated_ to the real class, but
128: // A simple packet stream class.  None of its members is virtual.
129: class ConcretePacketStream {
137: // A mock packet stream class.  It inherits from no other, but defines
139: class MockPacketStream {
147: Note that the mock class doesn't define `AppendPacket()`, unlike the
148: real class. That's fine as long as the test doesn't need to call it.
164: template <class PacketStream>
167: template <class PacketStream>
168: class PacketReader {
191: code to use an interface (abstract class).
198: class FileInterface {
204: class File : public FileInterface {
237: Suppose your test uses a mock class `MockFoo`:
297: ...(58 bytes skipped)...rk for mock methods defined using the `MOCK_METHOD*` family of macros **directly** in the `MockFoo` class. If a mock method is defined in a **base class** of `MockFoo`, the "nice" or "strict" modifier may not affect it, depending on the compiler. In pa...(107 bytes skipped)...
299: ...(298 bytes skipped)...irtual method of `this` object, that method is treated as non-virtual.  In other words, to the base class's constructor or destructor, `this` object behaves like an instance of the base class, not the derived class.  This rule is required for safety.  Otherwise a base constructor may use members of a derived class before they are initialized, or a base destructor may use members of a derived class after they have been destroyed.)
309: class LogSink {
325: The trick is to re-dispatch the method in the mock class:
328: class ScopedMockLog : public LogSink {
350: the mock class much more user-friendly.
355: interfaces. In order to test your code that uses such a class (let's
362: extension point where subclasses can tweak your class' behavior. This
363: weakens your control on the class because now it's harder to maintain
364: the class' invariants. You should make a function virtual only when
368: coupling between the class and the tests - any small change in the
369: class may invalidate your tests and make test maintenance a pain.
372: to interfaces": instead of talking to the `Concrete` class, your code
385: ...(185 bytes skipped)...our need - you may add higher-level functionalities, rename stuff, etc instead of just trimming the class. This allows you to write your code (user of the interface) in a more natural way, which means it w...(71 bytes skipped)...
407: class Foo {
414: class FakeFoo : public Foo {
432: When you define the mock class using Google Mock, you can have it
433: delegate its default action to a fake class you already have, using
440: class MockFoo : public Foo {
487: ...(336 bytes skipped)... you place inside `Invoke()`), use a `static_cast` to specify the function's type. For instance, if class `Foo` has methods `char DoThis(int n)` and `bool DoThis(double x) const`, and you want to invoke th...(294 bytes skipped)...
491: why it may be a bad sign: Suppose you have a class `System` for
495: you mock out the entire `System` class, you'll have to provide a fake
523: class MockFoo : public Foo {
563: class Foo {
571: class MockFoo : public Foo {
583: (but it would be oh-so painful to have to define a new mock class
586: The trick is to leave a back door in your mock class for accessing the
587: real methods in the base class:
590: class MockFoo : public Foo {
716: // A base class and a child class.
717: class Base { ... };
718: class Derived : public Base { ... };
720: class MockFoo : public Foo {
750: class MockFoo : public Foo {
780: class MockPrinter : public Printer {
1109: class BarPlusBazEqMatcher : public MatcherInterface<const Foo&> {
1314: In Google Mock, `NiceMock` and `StrictMock` can be used to make a mock class "nice" or "strict". How does this affect uninteresting calls and unexpected calls?
1395: `InSequence` class), which we borrowed from jMock 2. It's less
1507: class MockFoo : public Foo {
1538: class MockFoo : public Foo {
1591: class MockFoo : public Foo {
1617: class MockMutator : public Mutator {
1646: class MockMutator : public Mutator {
1668: class MockArrayMutator : public ArrayMutator {
1687: class MockRolodex : public Rolodex {
1754: about. You can do this using the `::testing::DefaultValue` class
1758: class MockFoo : public Foo {
1830: class MockFoo : public Foo {
1838: class Helper {
1885: class MockFoo : public Foo {
1906: class MockFoo : public Foo {
2012: class MockFoo : public Foo {
2246: enum class AccessLevel { kInternal, kPublic };
2248: class Buzz {
2254: class Buzzer {
2263: A `Buzz` object represents a snippet being posted. A class that implements the
2272: class MockBuzzer : public Buzzer {
2279: Now that we have the mock class defined, we can use it in tests. In the
2377: class MockBuzzer : public Buzzer {
2406: a mock class is in generating its constructor and destructor, as they
2411: different types of methods, compiling your mock class can get really
2415: of your mock class' constructor and destructor out of the class body
2417: class in N files, the compiler only needs to generate its constructor
2421: mock class before applying this recipe:
2426: class MockFoo : public Foo {
2430:   // where this mock class is used.
2443: class MockFoo : public Foo {
2554:   // Class MockFunction<F> has exactly one mock method.  It is named
2596: effect. First, add a mock function `Die()` to your mock class and call
2600: class MockFoo : public Foo {
2602:   // Add the following two lines to the mock class.
2745: class MockFoo {
3062: class MatchResultListener {
3075: class MatcherInterface {
3107: class DivisibleBy7Matcher : public MatcherInterface<int> {
3134: class DivisibleBy7Matcher : public MatcherInterface<int> {
3176: class NotNullMatcher {
3178:   // To implement a polymorphic matcher, first define a COPYABLE class
3199: // To construct a polymorphic matcher, pass an instance of the class
3209: **Note:** Your polymorphic matcher class does **not** need to inherit from
3210: `MatcherInterface` or any other class, and its methods do **not** need
3228: class CardinalityInterface {
3251: class EvenNumberCardinality : public CardinalityInterface {
3286: in a namespace scope (i.e. not inside a class or function), you will
3526: template <typename F>class ActionInterface {
3545: class IncrementArgumentAction : public ActionInterface<IncrementMethod> {
3588: implementation class:
3591: class ReturnSecondArgumentAction {
3601: This implementation class does _not_ need to inherit from any
3602: particular class. What matters is that it must have a `Perform()`
3611: implementation class into the polymorphic action we need. It will be
3629: class MockFoo : public Foo {
152: in tests.  Since the functions are not virtual and the two classes are
194: introduce an interface for it and have a concrete subclass that calls
262: `NiceMock<MockFoo>` is a subclass of `MockFoo`, so it can be used
354: Often you may find yourself using classes that don't implement
365: there is a valid reason for a subclass to override it.
367: Mocking concrete classes directly is problematic as it creates a tight
1874: invoking an underlining nullary function. Needless to say, this can be
github.com/google/vulkan_test_applications:third_party/mathfu/dependencies/googletest/googlemock/docs/CookBook.md: [ master, ]
555: ## Delegating Calls to a Parent Class ##
93: ## Mocking Class Templates ##
13: # Creating Mock Classes #
351: ## Alternative to Mocking Concrete Classes ##
18: `public:` section of the mock class, regardless of the method being
19: mocked being `public`, `protected`, or `private` in the base class.
21: from outside of the mock class.  (Yes, C++ allows a subclass to change
22: the access level of a virtual function in the base class.)  Example:
25: class Foo {
37: class MockFoo : public Foo {
43:   // methods are protected or private in the base class.
54: class Foo {
69: class MockFoo : public Foo {
80: compiler will give you a warning about some methods in the base class
84: class MockFoo : public Foo {
95: To mock a class template, append `_T` to the `MOCK_*` macros:
99: class StackInterface {
109: class MockStack : public StackInterface<Elem> {
121: In this case, instead of sharing a common base class with the real
122: class, your mock class will be _unrelated_ to the real class, but
127: // A simple packet stream class.  None of its members is virtual.
128: class ConcretePacketStream {
136: // A mock packet stream class.  It inherits from no other, but defines
138: class MockPacketStream {
146: Note that the mock class doesn't define `AppendPacket()`, unlike the
147: real class. That's fine as long as the test doesn't need to call it.
163: template <class PacketStream>
166: template <class PacketStream>
167: class PacketReader {
190: code to use an interface (abstract class).
197: class FileInterface {
203: class File : public FileInterface {
236: Suppose your test uses a mock class `MockFoo`:
296: ...(58 bytes skipped)...rk for mock methods defined using the `MOCK_METHOD*` family of macros **directly** in the `MockFoo` class. If a mock method is defined in a **base class** of `MockFoo`, the "nice" or "strict" modifier may not affect it, depending on the compiler. In pa...(107 bytes skipped)...
298: ...(298 bytes skipped)...irtual method of `this` object, that method is treated as non-virtual.  In other words, to the base class's constructor or destructor, `this` object behaves like an instance of the base class, not the derived class.  This rule is required for safety.  Otherwise a base constructor may use members of a derived class before they are initialized, or a base destructor may use members of a derived class after they have been destroyed.)
308: class LogSink {
324: The trick is to re-dispatch the method in the mock class:
327: class ScopedMockLog : public LogSink {
349: the mock class much more user-friendly.
354: interfaces. In order to test your code that uses such a class (let's
361: extension point where subclasses can tweak your class' behavior. This
362: weakens your control on the class because now it's harder to maintain
363: the class' invariants. You should make a function virtual only when
367: coupling between the class and the tests - any small change in the
368: class may invalidate your tests and make test maintenance a pain.
371: to interfaces": instead of talking to the `Concrete` class, your code
384: ...(185 bytes skipped)...our need - you may add higher-level functionalities, rename stuff, etc instead of just trimming the class. This allows you to write your code (user of the interface) in a more natural way, which means it w...(71 bytes skipped)...
406: class Foo {
413: class FakeFoo : public Foo {
431: When you define the mock class using Google Mock, you can have it
432: delegate its default action to a fake class you already have, using
439: class MockFoo : public Foo {
486: ...(336 bytes skipped)... you place inside `Invoke()`), use a `static_cast` to specify the function's type. For instance, if class `Foo` has methods `char DoThis(int n)` and `bool DoThis(double x) const`, and you want to invoke th...(294 bytes skipped)...
490: why it may be a bad sign: Suppose you have a class `System` for
494: you mock out the entire `System` class, you'll have to provide a fake
522: class MockFoo : public Foo {
562: class Foo {
570: class MockFoo : public Foo {
582: (but it would be oh-so painful to have to define a new mock class
585: The trick is to leave a back door in your mock class for accessing the
586: real methods in the base class:
589: class MockFoo : public Foo {
715: // A base class and a child class.
716: class Base { ... };
717: class Derived : public Base { ... };
719: class MockFoo : public Foo {
749: class MockFoo : public Foo {
779: class MockPrinter : public Printer {
1107: class BarPlusBazEqMatcher : public MatcherInterface<const Foo&> {
1312: In Google Mock, `NiceMock` and `StrictMock` can be used to make a mock class "nice" or "strict". How does this affect uninteresting calls and unexpected calls?
1393: `InSequence` class), which we borrowed from jMock 2. It's less
1505: class MockFoo : public Foo {
1536: class MockFoo : public Foo {
1589: class MockFoo : public Foo {
1615: class MockMutator : public Mutator {
1644: class MockMutator : public Mutator {
1666: class MockArrayMutator : public ArrayMutator {
1685: class MockRolodex : public Rolodex {
1752: about. You can do this using the `::testing::DefaultValue` class
1756: class MockFoo : public Foo {
1828: class MockFoo : public Foo {
1836: class Helper {
1883: class MockFoo : public Foo {
1904: class MockFoo : public Foo {
2010: class MockFoo : public Foo {
2237: enum class AccessLevel { kInternal, kPublic };
2239: class Buzz {
2245: class Buzzer {
2254: A `Buzz` object represents a snippet being posted.  A class that implements the `Buzzer` interface is capable of creating and sharing `Buzz`.  Methods in `Buzz...(109 bytes skipped)...
2259: class MockBuzzer : public Buzzer {
2278: class MockBuzzer : public Buzzer {
2288: Note that there's no need to define or declare `DoShareBuzz()` in a base class.  You only need to define it as a `MOCK_METHOD` in the mock class.
2290: Now that we have the mock class defined, we can use it in tests.  In the following code examples, we assume that we have defined a ...(41 bytes skipped)...
2379: class MockBuzzer : public Buzzer {
2423: a mock class is in generating its constructor and destructor, as they
2428: different types of methods, compiling your mock class can get really
2432: of your mock class' constructor and destructor out of the class body
2434: class in N files, the compiler only needs to generate its constructor
2438: mock class before applying this recipe:
2443: class MockFoo : public Foo {
2447:   // where this mock class is used.
2460: class MockFoo : public Foo {
2571:   // Class MockFunction<F> has exactly one mock method.  It is named
2613: effect. First, add a mock function `Die()` to your mock class and call
2617: class MockFoo : public Foo {
2619:   // Add the following two lines to the mock class.
2762: class MockFoo {
3079: class MatchResultListener {
3092: class MatcherInterface {
3124: class DivisibleBy7Matcher : public MatcherInterface<int> {
3151: class DivisibleBy7Matcher : public MatcherInterface<int> {
3193: class NotNullMatcher {
3195:   // To implement a polymorphic matcher, first define a COPYABLE class
3216: // To construct a polymorphic matcher, pass an instance of the class
3226: **Note:** Your polymorphic matcher class does **not** need to inherit from
3227: `MatcherInterface` or any other class, and its methods do **not** need
3245: class CardinalityInterface {
3268: class EvenNumberCardinality : public CardinalityInterface {
3303: in a namespace scope (i.e. not inside a class or function), you will
3541: template <typename F>class ActionInterface {
3560: class IncrementArgumentAction : public ActionInterface<IncrementMethod> {
3603: implementation class:
3606: class ReturnSecondArgumentAction {
3616: This implementation class does _not_ need to inherit from any
3617: particular class. What matters is that it must have a `Perform()`
3626: implementation class into the polymorphic action we need. It will be
3644: class MockFoo : public Foo {
151: in tests.  Since the functions are not virtual and the two classes are
193: introduce an interface for it and have a concrete subclass that calls
261: `NiceMock<MockFoo>` is a subclass of `MockFoo`, so it can be used
353: Often you may find yourself using classes that don't implement
364: there is a valid reason for a subclass to override it.
366: Mocking concrete classes directly is problematic as it creates a tight
1872: invoking an underlining nullary function. Needless to say, this can be
github.com/google/vulkan_test_applications:third_party/mathfu/dependencies/googletest/googlemock/docs/v1_7/CookBook.md: [ master, ]
555: ## Delegating Calls to a Parent Class ##
93: ## Mocking Class Templates ##
13: # Creating Mock Classes #
351: ## Alternative to Mocking Concrete Classes ##
18: `public:` section of the mock class, regardless of the method being
19: mocked being `public`, `protected`, or `private` in the base class.
21: from outside of the mock class.  (Yes, C++ allows a subclass to change
22: the access level of a virtual function in the base class.)  Example:
25: class Foo {
37: class MockFoo : public Foo {
43:   // methods are protected or private in the base class.
54: class Foo {
69: class MockFoo : public Foo {
80: compiler will give you a warning about some methods in the base class
84: class MockFoo : public Foo {
95: To mock a class template, append `_T` to the `MOCK_*` macros:
99: class StackInterface {
109: class MockStack : public StackInterface<Elem> {
121: In this case, instead of sharing a common base class with the real
122: class, your mock class will be _unrelated_ to the real class, but
127: // A simple packet stream class.  None of its members is virtual.
128: class ConcretePacketStream {
136: // A mock packet stream class.  It inherits from no other, but defines
138: class MockPacketStream {
146: Note that the mock class doesn't define `AppendPacket()`, unlike the
147: real class. That's fine as long as the test doesn't need to call it.
163: template <class PacketStream>
166: template <class PacketStream>
167: class PacketReader {
190: code to use an interface (abstract class).
197: class FileInterface {
203: class File : public FileInterface {
236: Suppose your test uses a mock class `MockFoo`:
296: ...(58 bytes skipped)...rk for mock methods defined using the `MOCK_METHOD*` family of macros **directly** in the `MockFoo` class. If a mock method is defined in a **base class** of `MockFoo`, the "nice" or "strict" modifier may not affect it, depending on the compiler. In pa...(107 bytes skipped)...
298: ...(298 bytes skipped)...irtual method of `this` object, that method is treated as non-virtual.  In other words, to the base class's constructor or destructor, `this` object behaves like an instance of the base class, not the derived class.  This rule is required for safety.  Otherwise a base constructor may use members of a derived class before they are initialized, or a base destructor may use members of a derived class after they have been destroyed.)
308: class LogSink {
324: The trick is to re-dispatch the method in the mock class:
327: class ScopedMockLog : public LogSink {
349: the mock class much more user-friendly.
354: interfaces. In order to test your code that uses such a class (let's
361: extension point where subclasses can tweak your class' behavior. This
362: weakens your control on the class because now it's harder to maintain
363: the class' invariants. You should make a function virtual only when
367: coupling between the class and the tests - any small change in the
368: class may invalidate your tests and make test maintenance a pain.
371: to interfaces": instead of talking to the `Concrete` class, your code
384: ...(185 bytes skipped)...our need - you may add higher-level functionalities, rename stuff, etc instead of just trimming the class. This allows you to write your code (user of the interface) in a more natural way, which means it w...(71 bytes skipped)...
406: class Foo {
413: class FakeFoo : public Foo {
431: When you define the mock class using Google Mock, you can have it
432: delegate its default action to a fake class you already have, using
439: class MockFoo : public Foo {
486: ...(336 bytes skipped)... you place inside `Invoke()`), use a `static_cast` to specify the function's type. For instance, if class `Foo` has methods `char DoThis(int n)` and `bool DoThis(double x) const`, and you want to invoke th...(294 bytes skipped)...
490: why it may be a bad sign: Suppose you have a class `System` for
494: you mock out the entire `System` class, you'll have to provide a fake
522: class MockFoo : public Foo {
562: class Foo {
570: class MockFoo : public Foo {
582: (but it would be oh-so painful to have to define a new mock class
585: The trick is to leave a back door in your mock class for accessing the
586: real methods in the base class:
589: class MockFoo : public Foo {
715: // A base class and a child class.
716: class Base { ... };
717: class Derived : public Base { ... };
719: class MockFoo : public Foo {
749: class MockFoo : public Foo {
779: class MockPrinter : public Printer {
1108: class BarPlusBazEqMatcher : public MatcherInterface<const Foo&> {
1344: `InSequence` class), which we borrowed from jMock 2. It's less
1456: class MockFoo : public Foo {
1487: class MockFoo : public Foo {
1540: class MockFoo : public Foo {
1566: class MockMutator : public Mutator {
1595: class MockMutator : public Mutator {
1617: class MockArrayMutator : public ArrayMutator {
1636: class MockRolodex : public Rolodex {
1701: about. You can do this using the `::testing::DefaultValue` class
1705: class MockFoo : public Foo {
1777: class MockFoo : public Foo {
1785: class Helper {
1832: class MockFoo : public Foo {
1853: class MockFoo : public Foo {
1959: class MockFoo : public Foo {
2180: a mock class is in generating its constructor and destructor, as they
2185: different types of methods, compiling your mock class can get really
2189: of your mock class' constructor and destructor out of the class body
2191: class in N files, the compiler only needs to generate its constructor
2195: mock class before applying this recipe:
2200: class MockFoo : public Foo {
2204:   // where this mock class is used.
2217: class MockFoo : public Foo {
2328:   // Class MockFunction<F> has exactly one mock method.  It is named
2370: effect. First, add a mock function `Die()` to your mock class and call
2374: class MockFoo : public Foo {
2376:   // Add the following two lines to the mock class.
2519: class MockFoo {
2836: class MatchResultListener {
2849: class MatcherInterface {
2881: class DivisibleBy7Matcher : public MatcherInterface<int> {
2908: class DivisibleBy7Matcher : public MatcherInterface<int> {
2950: class NotNullMatcher {
2952:   // To implement a polymorphic matcher, first define a COPYABLE class
2973: // To construct a polymorphic matcher, pass an instance of the class
2983: **Note:** Your polymorphic matcher class does **not** need to inherit from
2984: `MatcherInterface` or any other class, and its methods do **not** need
3002: class CardinalityInterface {
3025: class EvenNumberCardinality : public CardinalityInterface {
3060: in a namespace scope (i.e. not inside a class or function), you will
3298: template <typename F>class ActionInterface {
3317: class IncrementArgumentAction : public ActionInterface<IncrementMethod> {
3360: implementation class:
3363: class ReturnSecondArgumentAction {
3373: This implementation class does _not_ need to inherit from any
3374: particular class. What matters is that it must have a `Perform()`
3383: implementation class into the polymorphic action we need. It will be
3401: class MockFoo : public Foo {
151: in tests.  Since the functions are not virtual and the two classes are
193: introduce an interface for it and have a concrete subclass that calls
261: `NiceMock<MockFoo>` is a subclass of `MockFoo`, so it can be used
353: Often you may find yourself using classes that don't implement
364: there is a valid reason for a subclass to override it.
366: Mocking concrete classes directly is problematic as it creates a tight
1821: invoking an underlining nullary function. Needless to say, this can be
github.com/grpc/grpc-node:packages/grpc-native-core/deps/grpc/third_party/bloaty/third_party/googletest/googlemock/docs/CookBook.md: [ master, ]
555: ## Delegating Calls to a Parent Class ##
93: ## Mocking Class Templates ##
13: # Creating Mock Classes #
351: ## Alternative to Mocking Concrete Classes ##
18: `public:` section of the mock class, regardless of the method being
19: mocked being `public`, `protected`, or `private` in the base class.
21: from outside of the mock class.  (Yes, C++ allows a subclass to change
22: the access level of a virtual function in the base class.)  Example:
25: class Foo {
37: class MockFoo : public Foo {
43:   // methods are protected or private in the base class.
54: class Foo {
69: class MockFoo : public Foo {
80: compiler will give you a warning about some methods in the base class
84: class MockFoo : public Foo {
95: To mock a class template, append `_T` to the `MOCK_*` macros:
99: class StackInterface {
109: class MockStack : public StackInterface<Elem> {
121: In this case, instead of sharing a common base class with the real
122: class, your mock class will be _unrelated_ to the real class, but
127: // A simple packet stream class.  None of its members is virtual.
128: class ConcretePacketStream {
136: // A mock packet stream class.  It inherits from no other, but defines
138: class MockPacketStream {
146: Note that the mock class doesn't define `AppendPacket()`, unlike the
147: real class. That's fine as long as the test doesn't need to call it.
163: template <class PacketStream>
166: template <class PacketStream>
167: class PacketReader {
190: code to use an interface (abstract class).
197: class FileInterface {
203: class File : public FileInterface {
236: Suppose your test uses a mock class `MockFoo`:
296: ...(58 bytes skipped)...rk for mock methods defined using the `MOCK_METHOD*` family of macros **directly** in the `MockFoo` class. If a mock method is defined in a **base class** of `MockFoo`, the "nice" or "strict" modifier may not affect it, depending on the compiler. In pa...(107 bytes skipped)...
298: ...(298 bytes skipped)...irtual method of `this` object, that method is treated as non-virtual.  In other words, to the base class's constructor or destructor, `this` object behaves like an instance of the base class, not the derived class.  This rule is required for safety.  Otherwise a base constructor may use members of a derived class before they are initialized, or a base destructor may use members of a derived class after they have been destroyed.)
308: class LogSink {
324: The trick is to re-dispatch the method in the mock class:
327: class ScopedMockLog : public LogSink {
349: the mock class much more user-friendly.
354: interfaces. In order to test your code that uses such a class (let's
361: extension point where subclasses can tweak your class' behavior. This
362: weakens your control on the class because now it's harder to maintain
363: the class' invariants. You should make a function virtual only when
367: coupling between the class and the tests - any small change in the
368: class may invalidate your tests and make test maintenance a pain.
371: to interfaces": instead of talking to the `Concrete` class, your code
384: ...(185 bytes skipped)...our need - you may add higher-level functionalities, rename stuff, etc instead of just trimming the class. This allows you to write your code (user of the interface) in a more natural way, which means it w...(71 bytes skipped)...
406: class Foo {
413: class FakeFoo : public Foo {
431: When you define the mock class using Google Mock, you can have it
432: delegate its default action to a fake class you already have, using
439: class MockFoo : public Foo {
486: ...(336 bytes skipped)... you place inside `Invoke()`), use a `static_cast` to specify the function's type. For instance, if class `Foo` has methods `char DoThis(int n)` and `bool DoThis(double x) const`, and you want to invoke th...(294 bytes skipped)...
490: why it may be a bad sign: Suppose you have a class `System` for
494: you mock out the entire `System` class, you'll have to provide a fake
522: class MockFoo : public Foo {
562: class Foo {
570: class MockFoo : public Foo {
582: (but it would be oh-so painful to have to define a new mock class
585: The trick is to leave a back door in your mock class for accessing the
586: real methods in the base class:
589: class MockFoo : public Foo {
715: // A base class and a child class.
716: class Base { ... };
717: class Derived : public Base { ... };
719: class MockFoo : public Foo {
749: class MockFoo : public Foo {
779: class MockPrinter : public Printer {
1107: class BarPlusBazEqMatcher : public MatcherInterface<const Foo&> {
1312: In Google Mock, `NiceMock` and `StrictMock` can be used to make a mock class "nice" or "strict". How does this affect uninteresting calls and unexpected calls?
1393: `InSequence` class), which we borrowed from jMock 2. It's less
1505: class MockFoo : public Foo {
1536: class MockFoo : public Foo {
1589: class MockFoo : public Foo {
1615: class MockMutator : public Mutator {
1644: class MockMutator : public Mutator {
1666: class MockArrayMutator : public ArrayMutator {
1685: class MockRolodex : public Rolodex {
1752: about. You can do this using the `::testing::DefaultValue` class
1756: class MockFoo : public Foo {
1828: class MockFoo : public Foo {
1836: class Helper {
1883: class MockFoo : public Foo {
1904: class MockFoo : public Foo {
2010: class MockFoo : public Foo {
2237: enum class AccessLevel { kInternal, kPublic };
2239: class Buzz {
2245: class Buzzer {
2254: A `Buzz` object represents a snippet being posted.  A class that implements the `Buzzer` interface is capable of creating and sharing `Buzz`.  Methods in `Buzz...(109 bytes skipped)...
2259: class MockBuzzer : public Buzzer {
2278: class MockBuzzer : public Buzzer {
2288: Note that there's no need to define or declare `DoShareBuzz()` in a base class.  You only need to define it as a `MOCK_METHOD` in the mock class.
2290: Now that we have the mock class defined, we can use it in tests.  In the following code examples, we assume that we have defined a ...(41 bytes skipped)...
2379: class MockBuzzer : public Buzzer {
2423: a mock class is in generating its constructor and destructor, as they
2428: different types of methods, compiling your mock class can get really
2432: of your mock class' constructor and destructor out of the class body
2434: class in N files, the compiler only needs to generate its constructor
2438: mock class before applying this recipe:
2443: class MockFoo : public Foo {
2447:   // where this mock class is used.
2460: class MockFoo : public Foo {
2571:   // Class MockFunction<F> has exactly one mock method.  It is named
2613: effect. First, add a mock function `Die()` to your mock class and call
2617: class MockFoo : public Foo {
2619:   // Add the following two lines to the mock class.
2762: class MockFoo {
3079: class MatchResultListener {
3092: class MatcherInterface {
3124: class DivisibleBy7Matcher : public MatcherInterface<int> {
3151: class DivisibleBy7Matcher : public MatcherInterface<int> {
3193: class NotNullMatcher {
3195:   // To implement a polymorphic matcher, first define a COPYABLE class
3216: // To construct a polymorphic matcher, pass an instance of the class
3226: **Note:** Your polymorphic matcher class does **not** need to inherit from
3227: `MatcherInterface` or any other class, and its methods do **not** need
3245: class CardinalityInterface {
3268: class EvenNumberCardinality : public CardinalityInterface {
3303: in a namespace scope (i.e. not inside a class or function), you will
3541: template <typename F>class ActionInterface {
3560: class IncrementArgumentAction : public ActionInterface<IncrementMethod> {
3603: implementation class:
3606: class ReturnSecondArgumentAction {
3616: This implementation class does _not_ need to inherit from any
3617: particular class. What matters is that it must have a `Perform()`
3626: implementation class into the polymorphic action we need. It will be
3644: class MockFoo : public Foo {
151: in tests.  Since the functions are not virtual and the two classes are
193: introduce an interface for it and have a concrete subclass that calls
261: `NiceMock<MockFoo>` is a subclass of `MockFoo`, so it can be used
353: Often you may find yourself using classes that don't implement
364: there is a valid reason for a subclass to override it.
366: Mocking concrete classes directly is problematic as it creates a tight
1872: invoking an underlining nullary function. Needless to say, this can be
github.com/grpc/grpc-node:packages/grpc-native-core/deps/grpc/third_party/bloaty/third_party/googletest/googlemock/docs/v1_7/CookBook.md: [ master, ] Duplicate result
github.com/googleapis/python-crc32c:crc32c/third_party/googletest/googlemock/docs/CookBook.md: [ master, ]
556: ## Delegating Calls to a Parent Class ##
94: ## Mocking Class Templates ##
13: # Creating Mock Classes #
352: ## Alternative to Mocking Concrete Classes ##
18: `public:` section of the mock class, regardless of the method being
19: mocked being `public`, `protected`, or `private` in the base class.
21: from outside of the mock class.  (Yes, C++ allows a subclass to specify
22: a different access level than the base class on a virtual function.)
26: class Foo {
38: class MockFoo : public Foo {
44:   // methods are protected or private in the base class.
55: class Foo {
70: class MockFoo : public Foo {
81: compiler will give you a warning about some methods in the base class
85: class MockFoo : public Foo {
96: To mock a class template, append `_T` to the `MOCK_*` macros:
100: class StackInterface {
110: class MockStack : public StackInterface<Elem> {
122: In this case, instead of sharing a common base class with the real
123: class, your mock class will be _unrelated_ to the real class, but
128: // A simple packet stream class.  None of its members is virtual.
129: class ConcretePacketStream {
137: // A mock packet stream class.  It inherits from no other, but defines
139: class MockPacketStream {
147: Note that the mock class doesn't define `AppendPacket()`, unlike the
148: real class. That's fine as long as the test doesn't need to call it.
164: template <class PacketStream>
167: template <class PacketStream>
168: class PacketReader {
191: code to use an interface (abstract class).
198: class FileInterface {
204: class File : public FileInterface {
237: Suppose your test uses a mock class `MockFoo`:
297: ...(58 bytes skipped)...rk for mock methods defined using the `MOCK_METHOD*` family of macros **directly** in the `MockFoo` class. If a mock method is defined in a **base class** of `MockFoo`, the "nice" or "strict" modifier may not affect it, depending on the compiler. In pa...(107 bytes skipped)...
299: ...(298 bytes skipped)...irtual method of `this` object, that method is treated as non-virtual.  In other words, to the base class's constructor or destructor, `this` object behaves like an instance of the base class, not the derived class.  This rule is required for safety.  Otherwise a base constructor may use members of a derived class before they are initialized, or a base destructor may use members of a derived class after they have been destroyed.)
309: class LogSink {
325: The trick is to re-dispatch the method in the mock class:
328: class ScopedMockLog : public LogSink {
350: the mock class much more user-friendly.
355: interfaces. In order to test your code that uses such a class (let's
362: extension point where subclasses can tweak your class' behavior. This
363: weakens your control on the class because now it's harder to maintain
364: the class' invariants. You should make a function virtual only when
368: coupling between the class and the tests - any small change in the
369: class may invalidate your tests and make test maintenance a pain.
372: to interfaces": instead of talking to the `Concrete` class, your code
385: ...(185 bytes skipped)...our need - you may add higher-level functionalities, rename stuff, etc instead of just trimming the class. This allows you to write your code (user of the interface) in a more natural way, which means it w...(71 bytes skipped)...
407: class Foo {
414: class FakeFoo : public Foo {
432: When you define the mock class using Google Mock, you can have it
433: delegate its default action to a fake class you already have, using
440: class MockFoo : public Foo {
487: ...(336 bytes skipped)... you place inside `Invoke()`), use a `static_cast` to specify the function's type. For instance, if class `Foo` has methods `char DoThis(int n)` and `bool DoThis(double x) const`, and you want to invoke th...(294 bytes skipped)...
491: why it may be a bad sign: Suppose you have a class `System` for
495: you mock out the entire `System` class, you'll have to provide a fake
523: class MockFoo : public Foo {
563: class Foo {
571: class MockFoo : public Foo {
583: (but it would be oh-so painful to have to define a new mock class
586: The trick is to leave a back door in your mock class for accessing the
587: real methods in the base class:
590: class MockFoo : public Foo {
716: // A base class and a child class.
717: class Base { ... };
718: class Derived : public Base { ... };
720: class MockFoo : public Foo {
750: class MockFoo : public Foo {
780: class MockPrinter : public Printer {
1109: class BarPlusBazEqMatcher : public MatcherInterface<const Foo&> {
1314: In Google Mock, `NiceMock` and `StrictMock` can be used to make a mock class "nice" or "strict". How does this affect uninteresting calls and unexpected calls?
1395: `InSequence` class), which we borrowed from jMock 2. It's less
1507: class MockFoo : public Foo {
1538: class MockFoo : public Foo {
1591: class MockFoo : public Foo {
1617: class MockMutator : public Mutator {
1646: class MockMutator : public Mutator {
1668: class MockArrayMutator : public ArrayMutator {
1687: class MockRolodex : public Rolodex {
1754: about. You can do this using the `::testing::DefaultValue` class
1758: class MockFoo : public Foo {
1830: class MockFoo : public Foo {
1838: class Helper {
1885: class MockFoo : public Foo {
1906: class MockFoo : public Foo {
2012: class MockFoo : public Foo {
2246: enum class AccessLevel { kInternal, kPublic };
2248: class Buzz {
2254: class Buzzer {
2263: A `Buzz` object represents a snippet being posted. A class that implements the
2272: class MockBuzzer : public Buzzer {
2279: Now that we have the mock class defined, we can use it in tests. In the
2377: class MockBuzzer : public Buzzer {
2406: a mock class is in generating its constructor and destructor, as they
2411: different types of methods, compiling your mock class can get really
2415: of your mock class' constructor and destructor out of the class body
2417: class in N files, the compiler only needs to generate its constructor
2421: mock class before applying this recipe:
2426: class MockFoo : public Foo {
2430:   // where this mock class is used.
2443: class MockFoo : public Foo {
2554:   // Class MockFunction<F> has exactly one mock method.  It is named
2596: effect. First, add a mock function `Die()` to your mock class and call
2600: class MockFoo : public Foo {
2602:   // Add the following two lines to the mock class.
2745: class MockFoo {
3062: class MatchResultListener {
3075: class MatcherInterface {
3107: class DivisibleBy7Matcher : public MatcherInterface<int> {
3134: class DivisibleBy7Matcher : public MatcherInterface<int> {
3176: class NotNullMatcher {
3178:   // To implement a polymorphic matcher, first define a COPYABLE class
3199: // To construct a polymorphic matcher, pass an instance of the class
3209: **Note:** Your polymorphic matcher class does **not** need to inherit from
3210: `MatcherInterface` or any other class, and its methods do **not** need
3228: class CardinalityInterface {
3251: class EvenNumberCardinality : public CardinalityInterface {
3286: in a namespace scope (i.e. not inside a class or function), you will
3526: template <typename F>class ActionInterface {
3545: class IncrementArgumentAction : public ActionInterface<IncrementMethod> {
3588: implementation class:
3591: class ReturnSecondArgumentAction {
3601: This implementation class does _not_ need to inherit from any
3602: particular class. What matters is that it must have a `Perform()`
3611: implementation class into the polymorphic action we need. It will be
3629: class MockFoo : public Foo {
152: in tests.  Since the functions are not virtual and the two classes are
194: introduce an interface for it and have a concrete subclass that calls
262: `NiceMock<MockFoo>` is a subclass of `MockFoo`, so it can be used
354: Often you may find yourself using classes that don't implement
365: there is a valid reason for a subclass to override it.
367: Mocking concrete classes directly is problematic as it creates a tight
1874: invoking an underlining nullary function. Needless to say, this can be
github.com/apache/hawq:depends/thirdparty/googletest/googlemock/docs/CookBook.md: [ master, ]
555: ## Delegating Calls to a Parent Class ##
93: ## Mocking Class Templates ##
13: # Creating Mock Classes #
351: ## Alternative to Mocking Concrete Classes ##
18: `public:` section of the mock class, regardless of the method being
19: mocked being `public`, `protected`, or `private` in the base class.
21: from outside of the mock class.  (Yes, C++ allows a subclass to change
22: the access level of a virtual function in the base class.)  Example:
25: class Foo {
37: class MockFoo : public Foo {
43:   // methods are protected or private in the base class.
54: class Foo {
69: class MockFoo : public Foo {
80: compiler will give you a warning about some methods in the base class
84: class MockFoo : public Foo {
95: To mock a class template, append `_T` to the `MOCK_*` macros:
99: class StackInterface {
109: class MockStack : public StackInterface<Elem> {
121: In this case, instead of sharing a common base class with the real
122: class, your mock class will be _unrelated_ to the real class, but
127: // A simple packet stream class.  None of its members is virtual.
128: class ConcretePacketStream {
136: // A mock packet stream class.  It inherits from no other, but defines
138: class MockPacketStream {
146: Note that the mock class doesn't define `AppendPacket()`, unlike the
147: real class. That's fine as long as the test doesn't need to call it.
163: template <class PacketStream>
166: template <class PacketStream>
167: class PacketReader {
190: code to use an interface (abstract class).
197: class FileInterface {
203: class File : public FileInterface {
236: Suppose your test uses a mock class `MockFoo`:
296: ...(58 bytes skipped)...rk for mock methods defined using the `MOCK_METHOD*` family of macros **directly** in the `MockFoo` class. If a mock method is defined in a **base class** of `MockFoo`, the "nice" or "strict" modifier may not affect it, depending on the compiler. In pa...(107 bytes skipped)...
298: ...(298 bytes skipped)...irtual method of `this` object, that method is treated as non-virtual.  In other words, to the base class's constructor or destructor, `this` object behaves like an instance of the base class, not the derived class.  This rule is required for safety.  Otherwise a base constructor may use members of a derived class before they are initialized, or a base destructor may use members of a derived class after they have been destroyed.)
308: class LogSink {
324: The trick is to re-dispatch the method in the mock class:
327: class ScopedMockLog : public LogSink {
349: the mock class much more user-friendly.
354: interfaces. In order to test your code that uses such a class (let's
361: extension point where subclasses can tweak your class' behavior. This
362: weakens your control on the class because now it's harder to maintain
363: the class' invariants. You should make a function virtual only when
367: coupling between the class and the tests - any small change in the
368: class may invalidate your tests and make test maintenance a pain.
371: to interfaces": instead of talking to the `Concrete` class, your code
384: ...(185 bytes skipped)...our need - you may add higher-level functionalities, rename stuff, etc instead of just trimming the class. This allows you to write your code (user of the interface) in a more natural way, which means it w...(71 bytes skipped)...
406: class Foo {
413: class FakeFoo : public Foo {
431: When you define the mock class using Google Mock, you can have it
432: delegate its default action to a fake class you already have, using
439: class MockFoo : public Foo {
486: ...(336 bytes skipped)... you place inside `Invoke()`), use a `static_cast` to specify the function's type. For instance, if class `Foo` has methods `char DoThis(int n)` and `bool DoThis(double x) const`, and you want to invoke th...(294 bytes skipped)...
490: why it may be a bad sign: Suppose you have a class `System` for
494: you mock out the entire `System` class, you'll have to provide a fake
522: class MockFoo : public Foo {
562: class Foo {
570: class MockFoo : public Foo {
582: (but it would be oh-so painful to have to define a new mock class
585: The trick is to leave a back door in your mock class for accessing the
586: real methods in the base class:
589: class MockFoo : public Foo {
715: // A base class and a child class.
716: class Base { ... };
717: class Derived : public Base { ... };
719: class MockFoo : public Foo {
749: class MockFoo : public Foo {
779: class MockPrinter : public Printer {
1107: class BarPlusBazEqMatcher : public MatcherInterface<const Foo&> {
1312: In Google Mock, `NiceMock` and `StrictMock` can be used to make a mock class "nice" or "strict". How does this affect uninteresting calls and unexpected calls?
1393: `InSequence` class), which we borrowed from jMock 2. It's less
1505: class MockFoo : public Foo {
1536: class MockFoo : public Foo {
1589: class MockFoo : public Foo {
1615: class MockMutator : public Mutator {
1644: class MockMutator : public Mutator {
1666: class MockArrayMutator : public ArrayMutator {
1685: class MockRolodex : public Rolodex {
1752: about. You can do this using the `::testing::DefaultValue` class
1756: class MockFoo : public Foo {
1828: class MockFoo : public Foo {
1836: class Helper {
1883: class MockFoo : public Foo {
1904: class MockFoo : public Foo {
2010: class MockFoo : public Foo {
2237: enum class AccessLevel { kInternal, kPublic };
2239: class Buzz {
2245: class Buzzer {
2254: A `Buzz` object represents a snippet being posted.  A class that implements the `Buzzer` interface is capable of creating and sharing `Buzz`.  Methods in `Buzz...(109 bytes skipped)...
2259: class MockBuzzer : public Buzzer {
2278: class MockBuzzer : public Buzzer {
2288: Note that there's no need to define or declare `DoShareBuzz()` in a base class.  You only need to define it as a `MOCK_METHOD` in the mock class.
2290: Now that we have the mock class defined, we can use it in tests.  In the following code examples, we assume that we have defined a ...(41 bytes skipped)...
2379: class MockBuzzer : public Buzzer {
2423: a mock class is in generating its constructor and destructor, as they
2428: different types of methods, compiling your mock class can get really
2432: of your mock class' constructor and destructor out of the class body
2434: class in N files, the compiler only needs to generate its constructor
2438: mock class before applying this recipe:
2443: class MockFoo : public Foo {
2447:   // where this mock class is used.
2460: class MockFoo : public Foo {
2571:   // Class MockFunction<F> has exactly one mock method.  It is named
2613: effect. First, add a mock function `Die()` to your mock class and call
2617: class MockFoo : public Foo {
2619:   // Add the following two lines to the mock class.
2762: class MockFoo {
3079: class MatchResultListener {
3092: class MatcherInterface {
3124: class DivisibleBy7Matcher : public MatcherInterface<int> {
3151: class DivisibleBy7Matcher : public MatcherInterface<int> {
3193: class NotNullMatcher {
3195:   // To implement a polymorphic matcher, first define a COPYABLE class
3216: // To construct a polymorphic matcher, pass an instance of the class
3226: **Note:** Your polymorphic matcher class does **not** need to inherit from
3227: `MatcherInterface` or any other class, and its methods do **not** need
3245: class CardinalityInterface {
3268: class EvenNumberCardinality : public CardinalityInterface {
3303: in a namespace scope (i.e. not inside a class or function), you will
3541: template <typename F>class ActionInterface {
3560: class IncrementArgumentAction : public ActionInterface<IncrementMethod> {
3603: implementation class:
3606: class ReturnSecondArgumentAction {
3616: This implementation class does _not_ need to inherit from any
3617: particular class. What matters is that it must have a `Perform()`
3626: implementation class into the polymorphic action we need. It will be
3644: class MockFoo : public Foo {
151: in tests.  Since the functions are not virtual and the two classes are
193: introduce an interface for it and have a concrete subclass that calls
261: `NiceMock<MockFoo>` is a subclass of `MockFoo`, so it can be used
353: Often you may find yourself using classes that don't implement
364: there is a valid reason for a subclass to override it.
366: Mocking concrete classes directly is problematic as it creates a tight
1872: invoking an underlining nullary function. Needless to say, this can be
github.com/apache/hawq:depends/thirdparty/googletest/googlemock/docs/v1_7/CookBook.md: [ master, ] Duplicate result
github.com/google/brunsli:third_party/googletest/googlemock/docs/CookBook.md: [ master, ] Duplicate result
github.com/tesseract-ocr/tesseract:googletest/googlemock/docs/CookBook.md: [ master, ] Duplicate result
github.com/googlearchive/nxt-standalone:third_party/googletest/googlemock/docs/CookBook.md: [ master, ]
556: ## Delegating Calls to a Parent Class ##
94: ## Mocking Class Templates ##
13: # Creating Mock Classes #
352: ## Alternative to Mocking Concrete Classes ##
18: `public:` section of the mock class, regardless of the method being
19: mocked being `public`, `protected`, or `private` in the base class.
21: from outside of the mock class.  (Yes, C++ allows a subclass to specify
22: a different access level than the base class on a virtual function.)
26: class Foo {
38: class MockFoo : public Foo {
44:   // methods are protected or private in the base class.
55: class Foo {
70: class MockFoo : public Foo {
81: compiler will give you a warning about some methods in the base class
85: class MockFoo : public Foo {
96: To mock a class template, append `_T` to the `MOCK_*` macros:
100: class StackInterface {
110: class MockStack : public StackInterface<Elem> {
122: In this case, instead of sharing a common base class with the real
123: class, your mock class will be _unrelated_ to the real class, but
128: // A simple packet stream class.  None of its members is virtual.
129: class ConcretePacketStream {
137: // A mock packet stream class.  It inherits from no other, but defines
139: class MockPacketStream {
147: Note that the mock class doesn't define `AppendPacket()`, unlike the
148: real class. That's fine as long as the test doesn't need to call it.
164: template <class PacketStream>
167: template <class PacketStream>
168: class PacketReader {
191: code to use an interface (abstract class).
198: class FileInterface {
204: class File : public FileInterface {
237: Suppose your test uses a mock class `MockFoo`:
297: ...(58 bytes skipped)...rk for mock methods defined using the `MOCK_METHOD*` family of macros **directly** in the `MockFoo` class. If a mock method is defined in a **base class** of `MockFoo`, the "nice" or "strict" modifier may not affect it, depending on the compiler. In pa...(107 bytes skipped)...
299: ...(298 bytes skipped)...irtual method of `this` object, that method is treated as non-virtual.  In other words, to the base class's constructor or destructor, `this` object behaves like an instance of the base class, not the derived class.  This rule is required for safety.  Otherwise a base constructor may use members of a derived class before they are initialized, or a base destructor may use members of a derived class after they have been destroyed.)
309: class LogSink {
325: The trick is to re-dispatch the method in the mock class:
328: class ScopedMockLog : public LogSink {
350: the mock class much more user-friendly.
355: interfaces. In order to test your code that uses such a class (let's
362: extension point where subclasses can tweak your class' behavior. This
363: weakens your control on the class because now it's harder to maintain
364: the class' invariants. You should make a function virtual only when
368: coupling between the class and the tests - any small change in the
369: class may invalidate your tests and make test maintenance a pain.
372: to interfaces": instead of talking to the `Concrete` class, your code
385: ...(185 bytes skipped)...our need - you may add higher-level functionalities, rename stuff, etc instead of just trimming the class. This allows you to write your code (user of the interface) in a more natural way, which means it w...(71 bytes skipped)...
407: class Foo {
414: class FakeFoo : public Foo {
432: When you define the mock class using Google Mock, you can have it
433: delegate its default action to a fake class you already have, using
440: class MockFoo : public Foo {
487: ...(336 bytes skipped)... you place inside `Invoke()`), use a `static_cast` to specify the function's type. For instance, if class `Foo` has methods `char DoThis(int n)` and `bool DoThis(double x) const`, and you want to invoke th...(294 bytes skipped)...
491: why it may be a bad sign: Suppose you have a class `System` for
495: you mock out the entire `System` class, you'll have to provide a fake
523: class MockFoo : public Foo {
563: class Foo {
571: class MockFoo : public Foo {
583: (but it would be oh-so painful to have to define a new mock class
586: The trick is to leave a back door in your mock class for accessing the
587: real methods in the base class:
590: class MockFoo : public Foo {
716: // A base class and a child class.
717: class Base { ... };
718: class Derived : public Base { ... };
720: class MockFoo : public Foo {
750: class MockFoo : public Foo {
780: class MockPrinter : public Printer {
1109: class BarPlusBazEqMatcher : public MatcherInterface<const Foo&> {
1314: In Google Mock, `NiceMock` and `StrictMock` can be used to make a mock class "nice" or "strict". How does this affect uninteresting calls and unexpected calls?
1395: `InSequence` class), which we borrowed from jMock 2. It's less
1507: class MockFoo : public Foo {
1538: class MockFoo : public Foo {
1591: class MockFoo : public Foo {
1617: class MockMutator : public Mutator {
1646: class MockMutator : public Mutator {
1668: class MockArrayMutator : public ArrayMutator {
1687: class MockRolodex : public Rolodex {
1754: about. You can do this using the `::testing::DefaultValue` class
1758: class MockFoo : public Foo {
1830: class MockFoo : public Foo {
1838: class Helper {
1885: class MockFoo : public Foo {
1906: class MockFoo : public Foo {
2012: class MockFoo : public Foo {
2246: enum class AccessLevel { kInternal, kPublic };
2248: class Buzz {
2254: class Buzzer {
2263: A `Buzz` object represents a snippet being posted. A class that implements the
2272: class MockBuzzer : public Buzzer {
2279: Now that we have the mock class defined, we can use it in tests. In the
2377: class MockBuzzer : public Buzzer {
2406: a mock class is in generating its constructor and destructor, as they
2411: different types of methods, compiling your mock class can get really
2415: of your mock class' constructor and destructor out of the class body
2417: class in N files, the compiler only needs to generate its constructor
2421: mock class before applying this recipe:
2426: class MockFoo : public Foo {
2430:   // where this mock class is used.
2443: class MockFoo : public Foo {
2554:   // Class MockFunction<F> has exactly one mock method.  It is named
2596: effect. First, add a mock function `Die()` to your mock class and call
2600: class MockFoo : public Foo {
2602:   // Add the following two lines to the mock class.
2745: class MockFoo {
3062: class MatchResultListener {
3075: class MatcherInterface {
3107: class DivisibleBy7Matcher : public MatcherInterface<int> {
3134: class DivisibleBy7Matcher : public MatcherInterface<int> {
3176: class NotNullMatcher {
3178:   // To implement a polymorphic matcher, first define a COPYABLE class
3199: // To construct a polymorphic matcher, pass an instance of the class
3209: **Note:** Your polymorphic matcher class does **not** need to inherit from
3210: `MatcherInterface` or any other class, and its methods do **not** need
3228: class CardinalityInterface {
3251: class EvenNumberCardinality : public CardinalityInterface {
3286: in a namespace scope (i.e. not inside a class or function), you will
3526: template <typename F>class ActionInterface {
3545: class IncrementArgumentAction : public ActionInterface<IncrementMethod> {
3588: implementation class:
3591: class ReturnSecondArgumentAction {
3601: This implementation class does _not_ need to inherit from any
3602: particular class. What matters is that it must have a `Perform()`
3611: implementation class into the polymorphic action we need. It will be
3629: class MockFoo : public Foo {
152: in tests.  Since the functions are not virtual and the two classes are
194: introduce an interface for it and have a concrete subclass that calls
262: `NiceMock<MockFoo>` is a subclass of `MockFoo`, so it can be used
354: Often you may find yourself using classes that don't implement
365: there is a valid reason for a subclass to override it.
367: Mocking concrete classes directly is problematic as it creates a tight
1874: invoking an underlining nullary function. Needless to say, this can be
android.googlesource.com/platform/superproject:external/protobuf/third_party/googletest/googlemock/docs/CookBook.md: [ master, ] Duplicate result
github.com/grpc/grpc-web:third_party/grpc/third_party/bloaty/third_party/googletest/googlemock/docs/CookBook.md: [ master, ] Duplicate result
github.com/grpc/grpc:third_party/bloaty/third_party/googletest/googlemock/docs/CookBook.md: [ master, ] Duplicate result
github.com/grpc/grpc:third_party/bloaty/third_party/googletest/googlemock/docs/v1_7/CookBook.md: [ master, ] Duplicate result
github.com/google/swiftshader:third_party/googletest/googlemock/docs/CookBook.md: [ master, ] Duplicate result
swiftshader.googlesource.com/SwiftShader:third_party/googletest/googlemock/docs/CookBook.md: [ master, ] Duplicate result
android.googlesource.com/platform/external/protobuf:third_party/googletest/googlemock/docs/CookBook.md: [ master, ] Duplicate result
github.com/deepmind/spiral:third_party/swiftshader/third_party/googletest/googlemock/docs/CookBook.md: [ master, ] Duplicate result
github.com/apache/incubator-mxnet:3rdparty/googletest/googlemock/docs/CookBook.md: [ master, ] Duplicate result
github.com/apache/incubator-weex:weex_core/test/third_party/googletest/googlemock/docs/CookBook.md: [ master, ] Duplicate result
github.com/apache/incubator-pagespeed-mod:third_party/grpc/src/third_party/googletest/googlemock/docs/CookBook.md: [ master, ] Duplicate result
github.com/apache/incubator-pagespeed-mod:third_party/grpc/src/third_party/googletest/googlemock/docs/v1_7/CookBook.md: [ master, ] Duplicate result
github.com/google/error-prone:check_api/src/main/java/com/google/errorprone/names/NeedlemanWunschEditDistance.java: [ master, ]
33: public final class NeedlemanWunschEditDistance {
35:   private NeedlemanWunschEditDistance() {
23:  * The Needleman-Wunsch algorithm for finding least-cost string edit distances between pairs of
29:  * <p>See http://en.wikipedia.org/wiki/Needleman-Wunsch_algorithm
github.com/gwtproject/gwt:user/test/com/google/gwt/uibinder/test/client/NeedlesslyAnnotatedLabel.java: [ master, ]
25: public class NeedlesslyAnnotatedLabel extends Label {
26:   @UiConstructor public NeedlesslyAnnotatedLabel() {
gwt.googlesource.com/gwt:user/test/com/google/gwt/uibinder/test/client/NeedlesslyAnnotatedLabel.java: [ master, ] Duplicate result
github.com/apache/kudu:www/epoch.0.5.2.min.js: [ master, ]
78: return this.drawNeedle()}};d.prototype.drawNeedle=function(){var c,a,d;d=[this.centerX(),this.centerY(),this.radius()];c=d[0];a=d[1];d=d[2];this.setS...(357 bytes skipped)...
24: ...(118 bytes skipped)...s.rightAxis())};d.prototype._drawAxes=function(){this.hasAxis("bottom")&&this.svg.append("g").attr("class...(48 bytes skipped)..., "+this.innerHeight()+")").call(this.bottomAxis());this.hasAxis("top")&&this.svg.append("g").attr("class","x axis top").call(this.topAxis());this.hasAxis("left")&&this.svg.append("g").attr("class","y axis left").call(this.leftAxis());
25: this.hasAxis("right")&&this.svg.append("g").attr("class","y axis right").attr("transform","translate("+this.innerWidth()+", 0)").call(this.rightAxis());ret...(64 bytes skipped)...
28: a.enter().append("g").attr("class",function(a){return a.className});a.append("path").attr("class","area").attr("d",function(a){return c(a.values)});return e.__super__.draw.call(this)};return e}(Ep...(29 bytes skipped)...
34: function(a){return"translate("+e(a.group)+", 0)"});a.enter().append("g").attr("class...(246 bytes skipped)...r("width",f.rangeBand()).attr("height",function(a){return c-t(a.y)});d.enter().append("rect").attr("class",function(a){return a.className}).attr("x",function(a){return f(a.label)}).attr("y",
36: e(a.group)+")"});a.enter().append("g").attr("class...(239 bytes skipped)...ttr("height",f.rangeBand()).attr("width",function(a){return d(a.y)});c.enter().append("rect").attr("class",function(a){return a.className}).attr("x",function(a){return 0}).attr("y",function(a){return f(a.label)}).attr("height",
39: ...(118 bytes skipped)...").transition().duration(500).attr("d",function(c){return a(c.values)});c.enter().append("g").attr("class",function(a){return a.className}).append("path").attr("class","line").attr("d",function(c){return a(c.values)});c.exit().transition().duration(750).style("opaci...(95 bytes skipped)...
41: ...(228 bytes skipped)...l(".arc").data(this.pie(this.data),function(a){return a.data.category});c.enter().append("g").attr("class",function(a){return"arc pie "+a.data.className});c.select("path").attr("d",this.arc);c.select("text").attr("transform",function(c){return"tran...(26 bytes skipped)...
44: ...(30 bytes skipped)....svg.selectAll(".layer").data(this.data,function(a){return a.category});a.enter().append("g").attr("class",function(a){return a.class...(102 bytes skipped)...,function(a){return h(a.x)}).attr("cy",function(a){return e(a.y)});c.enter().append("circle").attr("class","dot").attr("r",this.options.radius).attr("cx",function(a){return h(a.x)}).attr("cy",function(a){r...(67 bytes skipped)...
50: ...(102 bytes skipped)...Axes=function(){var a,c,d,e,f;this.hasAxis("bottom")&&(a=this.bottomAxis=this.svg.append("g").attr("class...(65 bytes skipped)...gins.left-1)+", "+(this.innerHeight()/this.pixelRatio+this.margins.top)+")"),a.append("path").attr("class...(33 bytes skipped)...s.innerWidth()/this.pixelRatio+1)));this.hasAxis("top")&&(a=this.topAxis=this.svg.append("g").attr("class",
51: ...(23 bytes skipped)...tr("transform","translate("+(this.margins.left-1)+", "+this.margins.top+")"),a.append("path").attr("class","domain").attr("d","M0,0H"+(this.innerWidth()/this.pixelRatio+1)));e=this.options.ticks.time;this....(287 bytes skipped)...
52: function(){this.hasAxis("left")&&this.svg.append("g").attr("class...(77 bytes skipped)...s.margins.top+")").call(this.leftAxis());if(this.hasAxis("right"))return this.svg.append("g").attr("class","y axis right").attr("transform","translate("+(this.width-this.margins.right)+", "+this.margins.to...(189 bytes skipped)...
59: ...(266 bytes skipped)...),opacity:d?0:1,enter:d?!0:!1,exit:!1},this.hasAxis("bottom")&&(a=this.bottomAxis.append("g").attr("class","tick major").attr("transform","translate("+(c.x+1)+",0)").style("opacity",c.opacity),a.append("li...(54 bytes skipped)...
60: ...(50 bytes skipped)...ats.bottom(c.time)),c.bottomEl=jQuery(a[0])),this.hasAxis("top")&&(a=this.topAxis.append("g").attr("class","tick major").attr("transform","translate("+(c.x+1)+",0)").style("opacity",c.opacity),a.append("li...(258 bytes skipped)...
73: ...(22 bytes skipped)...s.el.get(0)).insert("svg",":first-child").attr("width",this.width).attr("height",this.height).attr("class...(87 bytes skipped)....append("g").attr("transform","translate("+this.textX()+", "+this.textY()+")").append("text").attr("class","value").text(this.options.format(this.value));this.animation={interval:null,active:!1,delta:0,tar...(97 bytes skipped)...
2: ...(399 bytes skipped)...ice(0,h)],a.slice(h+1)):d.createElement(a));if(f)if("$"==y&&(y=m[++z]),"#"==f)p.id=y;else if(l=(a=p.className)&&
3: (" "+a+" ").replace(" "+y+" "," "),"."==f)p.class...(57 bytes skipped)...v",p,"<").innerHTML="":(A=p.parentNode)&&A.removeChild(p)}else l=l.substring(1,l.length-1),l!=a&&(p.className=l);k&&("$"==w&&(w=m[++z]),"style"==k?p.style.cssText=w:(f="!"==k.charAt(0)?(k=k.substring(1))&&...(191 bytes skipped)...
13: ...(14 bytes skipped)...=["layer"],h.push("category"+c),d.category=c,null!=d.label&&h.push(Epoch.Util.dasherize(d.label)),d.className=h.join(" "),c++;return this.data=a};a.prototype.update=function(a,c){null==c&&(c=!0);this.setDa...(294 bytes skipped)...
17: ...(397 bytes skipped)...=f.length;q<p;q++)l=f[q],n=l.tagName.toLowerCase(),null!=l.id&&0<l.id.length&&(n+="#"+l.id),null!=l.className&&
18: 0<l.className.length&&(n+="."+jQuery.trim(l.className).replace(/\s+/g,".")),d.push(n);d.push("svg");q=jQuery.trim(a).split(/\s+/);f=0;for(n=q.length;...(295 bytes skipped)...
32: ...(276 bytes skipped)...ion(){var a,c,d,e,f,t,l,y,n,q,p,k;f={};p=this.data;t=0;for(y=p.length;t<y;t++)for(e=p[t],a="bar "+e.className.replace(/\s*layer\s*/,""),k=e.values,l=0,n=k.length;l<n;l++)c=k[l],null==f[q=c.x]&&(f[q]=[]),f[...(28 bytes skipped)...
33: y:c.y,className:a});c=[];for(d in f)a=f[d],c.push({group:d,values:a});return c};d.prototype.draw=function(){"ho...(405 bytes skipped)...
49: ...(387 bytes skipped)...(c),c=["layer"],c.push("category"+((e|0)+1)),null!=f.label&&c.push(Epoch.Util.dasherize(f.label)),d.className=c.join(" "),
65: ...(249 bytes skipped)... k=e.__super__.constructor.apply(this,arguments)}f(e,d);e.prototype.setStyles=function(c){c=null!=c.className?this.getStyles("g."+c.className.replace(/\s/g,".")+" path.area"):this.getStyles("g path.area");this.ctx.fillStyle=c.fill;null!=...(32 bytes skipped)...
70: ...(286 bytes skipped)...A[0];p=A[1];x=this.data;B=[];A=0;for(z=x.length;A<z;A++)n=x[A],0<n.values.length&&(this.setStyles(n.className),w=[this.options.windowSize,n.values.length,this.inTransition()],t=w[0],k=w[1],l=(q=w[2])?-1:0,...(24 bytes skipped)...
86: ...(9 bytes skipped)...e<n;e++){q=p[e];l=q.values[a];z=l.buckets;for(d in z)f=z[d],B[d]+=f;C+=l.max;f=this.getStyles("."+q.className.split(" ").join(".")+" rect.bucket");l.color=f.fill;k.push(l)}q=c*A;this.p.clearRect(q,0,A,this...(302 bytes skipped)...
90: ...(272 bytes skipped)...0];m=d[1];q=this.data;p=[];y=0;for(n=q.length;y<n;y++)if(f=q[y],0<f.values.length){this.setStyles(f.className);this.ctx.beginPath();k=[this.options.windowSize,f.values.length,this.inTransition()];d=k[0];e=...(25 bytes skipped)...
github.com/googleglass/gdk-compass-sample:app/src/main/java/com/google/android/glass/sample/compass/CompassView.java: [ master, ]
341:     private void drawNeedle(Canvas canvas, boolean bottom) {
50: public class CompassView extends View {
217:         drawNeedle(canvas, false);
218:         drawNeedle(canvas, true);
github.com/bazelbuild/bazel:src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java: [ master, ]
143:   private Artifact classJar;
802:   public Artifact getClassJar() {
80:  * A helper class for android rules.
85: public class AndroidCommon {
99:       RuleContext ruleContext, Mode mode, final Class<T> classType) {
186:         AnalysisUtils.getProviders(deps, AndroidNeverLinkLibrariesProvider.class)) {
193:           JavaInfo.getProvidersFromListOfTargets(JavaCompilationArgsProvider.class, deps)) {
365:       // Needle index is exhausted, so the needle must match.
400:         ruleContext.isLegalFragment(AndroidConfiguration.class)
401:             && ruleContext.getFragment(AndroidConfiguration.class).getExportsManifestDefault();
420:     // The resource class JAR should already have been generated.
423:             ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_CLASS_JAR)));
430:     // We don't actually use the ijar. That is almost the same as the resource class jar
464:     classJar = ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_LIBRARY_CLASS_JAR);
474:                       .getProvider(FileProvider.class)
709:             .addProvider(JavaCompilationArgsProvider.class, compilationArgsProvider)
710:             .addProvider(JavaRuleOutputJarsProvider.class, ruleOutputJarsProvider)
711:             .addProvider(JavaSourceJarsProvider.class, sourceJarsProvider)
712:             .addProvider(JavaPluginInfoProvider.class, JavaCommon.getTransitivePlugins(ruleContext))
719:             .getFragment(AndroidConfiguration.class)
736:         .addProvider(RunfilesProvider.class, RunfilesProvider.simple(getRunfiles()))
780:                 .getFragment(AndroidConfiguration.class)
856:     return context.getConfiguration().getFragment(AndroidConfiguration.class);
922:       FileProvider fileProvider = dep.getProvider(FileProvider.class);
939:    * into the same classloader. If the same class exists in both jars, there will be runtime
942:    * <p>R.class files that share the same package are also filtered out to prevent
957:             .addFileTypeToFilter(".class")
961:             .addExplicitFilter("/BR\\.class$")
962:             .addExplicitFilter("/databinding/[^/]+Binding\\.class$");
964:       builder.addExplicitFilter("R\\.class").addExplicitFilter("R\\$.*\\.class");
47: import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException;
56: import com.google.devtools.build.lib.rules.java.ClasspathConfiguredFragment;
60: import com.google.devtools.build.lib.rules.java.JavaCompilationArgsProvider.ClasspathType;
104:         builder.add(ruleContext.getPrerequisites(attr, mode, classType));
207:       Artifact classesDex,
229:     commandLine.addPrefixedExecPath("--output=", classesDex);
237:             .addOutput(classesDex)
427:     // Add the compiled resource jar to the classpath of the main compilation.
429:     // Add the compiled resource jar to the classpath of consuming targets.
465:     idlHelper = new AndroidIdlHelper(ruleContext, classJar);
524:       // Combined resource constants needs to come even before our own classes that may contain
561:     this.jarsProducedForRuntime = jarsProducedForRuntime.add(classJar).build();
578:     helper.addLibrariesToAttributes(javaCommon.targetsTreatedAsDeps(ClasspathType.COMPILE_ONLY));
603:       // We only want to add a jar to the classpath of a dependent rule if it has content.
604:       javaArtifactsBuilder.addRuntimeJar(classJar);
605:       jar = classJar;
608:     filesBuilder.add(classJar);
610:     outputs = helper.createOutputs(classJar);
643:         new ClasspathConfiguredFragment(
672:     idlHelper.addTransitiveInfoProviders(builder, classJar, outputs.manifestProto());
690:             .addOutputJar(classJar, iJar, outputs.manifestProto(), ImmutableList.of(srcJar))
700:         builder, javaInfoBuilder, filesToBuild, classJar, ANDROID_COLLECTION_SPEC);
703:         builder, javaInfoBuilder, outputs.genClass(), outputs.genSource());
794:    * Returns Jars produced by this rule that may go into the runtime classpath. By contrast {@link
795:    * #getRuntimeJars()} returns the complete runtime classpath needed by this rule, including
803:     return classJar;
816:         javaCommon.targetsTreatedAsDeps(ClasspathType.BOTH),
898:       compileDeps = JavaCommon.defaultDeps(ruleContext, semantics, ClasspathType.COMPILE_ONLY);
900:       runtimeDeps = JavaCommon.defaultDeps(ruleContext, semantics, ClasspathType.RUNTIME_ONLY);
901:       bothDeps = JavaCommon.defaultDeps(ruleContext, semantics, ClasspathType.BOTH);
937:    * Used for instrumentation tests. Filter out classes from the instrumentation JAR that are also
260:             .setIdlClassJar(idlHelper.getIdlClassJar())
306:     String packageName = JavaUtil.getJavaFullClassname(nameFragment);
413:       Artifact resourceJavaClassJar,
422:         resourceJavaClassJar.equals(
428:     attributes.addDirectJars(NestedSetBuilder.create(Order.STABLE_ORDER, resourceJavaClassJar));
433:     artifactsBuilder.addCompileTimeJarAsFullJar(resourceJavaClassJar);
437:     filesBuilder.add(resourceJavaClassJar);
444:         ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_SOURCE_JAR);
467:     ImmutableList<Artifact> bootclasspath;
469:       bootclasspath =
473:                       .getPrerequisite("$desugar_java8_extra_bootclasspath", Mode.HOST)
479:       bootclasspath =
491:             .setBootClassPath(bootclasspath);
514:       if (resourceApk.addResourcesClassJarToCompilationClasspath()) {
517:             resourceApk.getResourceJavaClassJar(),
526:       artifactsBuilder.addRuntimeJar(resourceApk.getResourceJavaClassJar());
527:       jarsProducedForRuntime.add(resourceApk.getResourceJavaClassJar());
559:       jarsProducedForRuntime.add(generatedExtensionRegistryProvider.getClassJar());
613:     srcJar = ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_LIBRARY_SOURCE_JAR);
642:     javaCommon.setClassPathFragment(
647:             helper.getBootclasspathOrDefault()));
678:     if (resourceApk.getResourceJavaClassJar() != null && resourceSourceJar != null) {
681:               resourceApk.getResourceJavaClassJar(),
930:         supportApks.addAll(FileType.filter(fileProvider.getFilesToBuild(), AndroidRuleClasses.APK));
951:       boolean removeAllRClasses) {
963:     if (removeAllRClasses) {
android.googlesource.com/platform/external/jetbrains/jdk8u_nashorn:docs/JavaScriptingProgrammersGuide.html: [ master, ]
477: <a name="jsjavaclass" id=jsjavalass"></a>
26: <html class=" regenabled  gecko radius jsenabled regloaded" xmlns="http://www.w3.org/1999/xhtml"><head>
37: <div id="sharepage" class="smallpagetitle"><h1>Java Scripting Programmer's Guide</h1><div class="sharepage">		<div class...(272 bytes skipped)...cs.oracle.com%2Fjavase%2F6%2Fdocs%2Ftechnotes%2Fguides%2Fscripting%2Fprogrammer_guide%2Findex.html" class...(146 bytes skipped)...cs.oracle.com%2Fjavase%2F6%2Fdocs%2Ftechnotes%2Fguides%2Fscripting%2Fprogrammer_guide%2Findex.html" class...(213 bytes skipped)...guides%2Fscripting%2Fprogrammer_guide%2Findex.html;title=Java%20Scripting%20Programmer%27s%20Guide" class...(211 bytes skipped)...es%2Fscripting%2Fprogrammer_guide%2Findex.html&amp;title=Java%20Scripting%20Programmer%27s%20Guide" class...(198 bytes skipped)...cs.oracle.com%2Fjavase%2F6%2Fdocs%2Ftechnotes%2Fguides%2Fscripting%2Fprogrammer_guide%2Findex.html" class="sharelink slashdot" title="Submit this page to Slashdot"></a></td>		<td id="share-blank"> </td></t...(36 bytes skipped)...
80: <li><span><a href="#classBoundImplementations">Class-Bound Implementations
132: of the scripting API is the <code>ScriptEngineManager</code> class.
168: public class EvalScript {
171:         <span class="classref">ScriptEngineManager</span> factory = new ScriptEngineManager();
173:         <span class="classref">ScriptEngine</span> engine = factory.<span class="methodref">getEngineByName</span>("nashorn");
175:         engine.<span class="methodref">eval</span>("print('Hello, World')");
194: public class EvalFile {
197:         <span class="classref">ScriptEngineManager</span> factory = new ScriptEngineManager();
199:         <span class="classref">ScriptEngine</span> engine = factory.<span class="methodref">getEngineByName</span>("nashorn");
201:         engine.<span class="methodref">eval</span>(new java.io.FileReader(args[0]));
246: public class ScriptVars { 
253:         engine.<span class="methodref">put</span>("file", f);
277: public class InvokeScriptFunction {
290:         <span class="classref">Invocable</span> inv = (Invocable) engine;
293:         inv.<span class="methodref">invokeFunction</span>("hello", "Scripting!!" );
307: public class InvokeScriptMethod {
321:         <span class="classref">Invocable</span> inv = (Invocable) engine;
324:         Object obj = engine.<span class="methodref">get</span>("obj");
327:         inv.<span class="methodref">invokeMethod</span>(obj, "hello", "Script Method !!" );
348: public class RunnableImpl {
359:         <span class="classref">Invocable</span> inv = (Invocable) engine;
363:         Runnable r = inv.<span class="methodref">getInterface</span>(Runnable.class);
384: public class RunnableImplObject {
396:         Object obj = engine.<span class="methodref">get</span>("obj");
398:         <span class="classref">Invocable</span> inv = (Invocable) engine;
402:         Runnable r = inv.<span class="methodref">getInterface</span>(obj, Runnable.class);
434: public class MultiScopes {
445:         <span class="classref">ScriptContext</span> newContext = new <span class="classref">SimpleScriptContext</span>();
447:         <span class="classref">Bindings</span> engineScope = newContext.<span class="methodref">getBindings</span>(ScriptContext.ENGINE_SCOPE);
450:         engineScope.<span class="methodref">put</span>("x", "world");
504: In the special case of inner classes, you can either use the JVM fully qualified name, meaning using the dollar sign in the class name, or you can use the dot:
516: ...(2 bytes skipped)...th work. Note however that using the dollar sign is faster, as Java.type first tries to resolve the class name as it is originally specified, and the internal JVM names for inner classes use the dollar sign. If you use the dot, Java.type will internally get a Class...(86 bytes skipped)... matter of fact, it'll keep replacing dots with dollar signs until it either successfully loads the class...(8 bytes skipped)... out of all dots in the name. This way it can correctly resolve and load even multiply nested inner class...(33 bytes skipped)...this will be slower than using the dollar signs in the name. An alternative way to access the inner class is as a property of the outer class:
523: You can access both static and non-static inner classes. If you want to create an instance of a non-static inner class, remember to pass an instance of its outer class as the first argument to the constructor.
536: A type object returned from <code>Java.type</code> is distinct from a <code>java.lang.Class</code> object. You can obtain one from the other using properties <code>class</code> and <code>static</code> on them.
543:  print("Class doesn't act as target of instanceof: " + !(a instanceof a.getClass()))
545:  print("Type's `class` property is same as instance getClass(): " + (a.getClass() === ArrayList.class))
549: You can think of the type object as similar to the class names as used in Java source code: you use them as the
551: and methods, but they are different than the runtime <code>Class</code> objects returned by <code>getClass()</code> calls.
553: between compile-time class expressions and runtime class objects also exists. (Also, Java can't have the equivalent of <code>static</code>
554: property on a <code>Class</code> object since compile-time class expressions are never reified as objects).
570: <span class="functionref">importPackage</span>(java.awt);
572: <span class="functionref">importClass</span>(java.awt.Frame);
581: <p>The <span class="objectref">Packages</span> global variable can
593: avoid that, you may use <span class="functionref">JavaImporter</span>.</p>
600: var SwingGui = new <span class="functionref">JavaImporter</span>(javax.swing,
660: Java anonymous class-like syntax:</p>
695: If a Java class is abstract, you can instantiate an anonymous subclass of it using an argument list that is applicable to any of its public or protected constructors, but...(230 bytes skipped)...
713: which is very similar to Java anonymous inner class definition. On the other hand, if the type is an abstract type with a single abstract method (commo...(210 bytes skipped)...
720: Note that in every one of these cases if you are trying to instantiate an abstract class that has constructors that take some arguments, you can invoke those simply by specifying the argum...(57 bytes skipped)...
736: To extend a concrete Java class, you have to use <code>Java.extend</code> function.
737: <code>Java.extend</code> returns a type object for a subclass of the specified Java class (or implementation of the specified interface) that acts as a script-to-Java adapter for it.  
775: ...(2 bytes skipped)...ode>Java.extend</code> can in fact take a list of multiple types. At most one of the types can be a class, and the rest must
776: be interfaces (the class doesn't have to be the first in the list). You will get back an object that extends the class and 
777: implements all the interfaces. (Obviously, if you only specify interfaces and no class, the object will extend <code>java.lang.Object</code>).
780: <h3>Class-Bound Implementations</h3>
785: to the actual instance being created with <code>new</code>, and not to the whole class. This has some advantages, for example in the
787: ...(8 bytes skipped)...ty, the below code shows that different instantiations of, say, <code>Runnable</code> have the same class regardless of them having
796: print("We share the same class: " + (r1.class === r2.class))
804: We share the same class: true
807: Sometimes, however, you'll want to extend a Java class or implement an interface with implementation bound to the class, not to
808: its instances. Such a need arises, for example, when you need to pass the class for instantiation to an external API; prime example
809: of this is the JavaFX framework where you need to pass an Application class to the FX API and let it instantiate it.
813: denoting a class to extend and interfaces to implement &ndash; can also take one last argument that has to be a Java...(13 bytes skipped)...
814: ...(6 bytes skipped)...erves as the implementation for the methods. In this case, <code>Java.extend()</code> will create a class that has the same
815: constructors as the original class had, as they don't need to take an an extra implementation object parameter. The example below
816: shows how you can create class-bound implementations, and shows that in this case, the implementation classes for different invocations
826: print("We share the same class: " + (r1.class === r2.class))
834: We share the same class: false
839: the implementations are bound to a class, the two classes obviously can't be the same, and we indeed see that the two runnables no
840: longer share the same class &ndash; every invocation of <code>Java.extend()</code> with a class-specific implementation object triggers
841: the creation of a new Java adapter class.
844: Finally, the adapter classes with class-bound implementations can <i>still</i> take an additional constructor parameter to further
846: in a class-based JavaScript implementation object passed to <code>Java.extend</code>, and part in another obje...(29 bytes skipped)...
847: ...(0 bytes skipped)...Whatever functions are provided by the constructor-passed object will override the functions in the class-bound object.
855: print("We share the same class: " + (r1.class === r2.class))
863: We share the same class: true
891: Note that you normally don't even have to use qualified class names in 
897: class.
929: end up with an object of private engine implementation class that implements <code>CharSequence</code> but is not a Java String.
938: abstract class <code>javax.script.AbstractScriptEngine</code>
957: <div class="hr"><hr></div>
973: <div class="hr"><hr></div>
8:  particular file as subject to the "Classpath" exception as provided
66: <li><span><a href="#jsjavaclass">Accessing Java
67: Classes</a></span></li>
69: Classes</a></span></li>
74: <li><span><a href="#jsextendabstract">Extending Abstract Java Classes
76: <li><span><a href="#jsextendconcrete">Extending Concrete Java Classes
161: Needless to say, you have to handle the exceptions
468: <p>For the most part, accessing Java classes, objects and methods
478: <h3>Accessing Java Classes</h3>
527: static fields and methods of the classes:
544:  print("Type is not same as instance's getClass(): " + (a.getClass() !== ArrayList))
546:  print("Type is same as instance getClass()'s `static` property: " + (a.getClass().static === ArrayList))
558: <h3>Importing Java Packages, Classes</h3>
560: <code>importClass</code> can be used to import Java packages and
561: classes.</p>
564: // <a href="source/importpackageclass.js">importpackageclass.js</a>
568: // Import Java packages and classes 
573: // Create Java Objects by "new ClassName"
587: platform classes can be accessed without the "Packages" prefix.</p>
591: <p><code>importPackage</code> and <code>importClass</code>
598: // create JavaImporter with specific packages and classes to import
606:     // classes by unqualified (simple) names.
693: <h3>Extending Abstract Java Classes</h3>
730: ...(35 bytes skipped)... expects a <code>TimerTask</code> as its argument, so Nashorn creates an instance of a TimerTask subclass and uses the passed function to implement its only abstract method, run(). In this usage though, yo...(130 bytes skipped)...
734: <h3>Extending Concrete Java Classes</h3>
760: The reason you must use <code>Java.extend()</code> with concrete classes is that with concrete classes, there can be a 
767: If we allowed subclassing of concrete classes with constructor syntax, Nashorn couldn't tell if you're creating a new 
779: <a name="classBoundImplementations" id="classBoundImplementations"></a>
782: The methods shown so far for extending Java classes and implementing interfaces &ndash; passing an implementation JavaScript object 
783: ...(6 bytes skipped)...ction to a constructor, or using <code>Java.extend</code> with <code>new</code> &ndash; all produce classes that take an
768: <code>Thread</code> and passing it a <code>Runnable</code> at this point, or you are subclassing <code>Thread</code> and
github.com/chromium/chromium:native_client_sdk/src/examples/api/mouse_lock/mouse_lock.cc: [ master, ]
266: void MouseLockInstance::DrawNeedle(pp::ImageData* image,
46:   RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE | PP_INPUTEVENT_CLASS_KEYBOARD);
348: class MouseLockModule : public pp::Module {
216:   DrawNeedle(&image, kForegroundColor);
269:     Log("DrawNeedle with NULL image");
chromium.googlesource.com/arc/arc:third_party/chromium-ppapi/native_client_sdk/src/examples/api/mouse_lock/mouse_lock.cc: [ master, ] Duplicate result