Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(503)

Side by Side Diff: media/base/mock_task.h

Issue 6056008: Move lots of GMock stuff out of line. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Copyright junk Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file provides some utility classes that help with testing APIs which use 5 // This file provides some utility classes that help with testing APIs which use
6 // callbacks. 6 // callbacks.
7 // 7 //
8 // -- InvokeRunnable -- 8 // -- InvokeRunnable --
9 // The InvokeRunnable is an action that can be used a gMock mock object to 9 // The InvokeRunnable is an action that can be used a gMock mock object to
10 // invoke the Run() method on mock argument. Example: 10 // invoke the Run() method on mock argument. Example:
11 // 11 //
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 namespace media { 57 namespace media {
58 58
59 ACTION(InvokeRunnable) { 59 ACTION(InvokeRunnable) {
60 arg0->Run(); 60 arg0->Run();
61 delete arg0; 61 delete arg0;
62 } 62 }
63 63
64 class TaskMocker { 64 class TaskMocker {
65 public: 65 public:
66 TaskMocker() 66 TaskMocker();
67 : outstanding_tasks_(0) { 67 ~TaskMocker();
68 }
69 ~TaskMocker() {
70 CHECK(outstanding_tasks_ == 0)
71 << "If outstanding_tasks_ is not zero, tasks have been leaked.";
72 }
73 68
74 Task* CreateTask() { 69 Task* CreateTask();
75 return new CountingTask(this);
76 }
77 70
78 MOCK_METHOD0(Run, void()); 71 MOCK_METHOD0(Run, void());
79 72
80 private: 73 private:
81 friend class CountingTask; 74 friend class CountingTask;
82 class CountingTask : public Task { 75 class CountingTask : public Task {
83 public: 76 public:
84 CountingTask(TaskMocker* origin) 77 CountingTask(TaskMocker* origin)
85 : origin_(origin) { 78 : origin_(origin) {
86 origin_->outstanding_tasks_++; 79 origin_->outstanding_tasks_++;
(...skipping 14 matching lines...) Expand all
101 }; 94 };
102 95
103 int outstanding_tasks_; 96 int outstanding_tasks_;
104 97
105 DISALLOW_COPY_AND_ASSIGN(TaskMocker); 98 DISALLOW_COPY_AND_ASSIGN(TaskMocker);
106 }; 99 };
107 100
108 } // namespace media 101 } // namespace media
109 102
110 #endif //MEDIA_BASE_MOCK_TASK_H_ 103 #endif //MEDIA_BASE_MOCK_TASK_H_
OLDNEW
« gpu/gpu.gyp ('K') | « media/base/mock_filters.cc ('k') | media/base/mock_task.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698