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

Side by Side Diff: content/browser/renderer_host/media/video_capture_host_unittest.cc

Issue 10068037: RefCounted types should not have public destructors, content/browser part 1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MSVC fixes Created 8 years, 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 int expected_size_; 69 int expected_size_;
70 }; 70 };
71 71
72 class MockVideoCaptureHost : public VideoCaptureHost { 72 class MockVideoCaptureHost : public VideoCaptureHost {
73 public: 73 public:
74 MockVideoCaptureHost(content::ResourceContext* resource_context, 74 MockVideoCaptureHost(content::ResourceContext* resource_context,
75 media::AudioManager* audio_manager) 75 media::AudioManager* audio_manager)
76 : VideoCaptureHost(resource_context, audio_manager), 76 : VideoCaptureHost(resource_context, audio_manager),
77 return_buffers_(false), 77 return_buffers_(false),
78 dump_video_(false) {} 78 dump_video_(false) {}
79 virtual ~MockVideoCaptureHost() {
80 STLDeleteContainerPairSecondPointers(filled_dib_.begin(),
81 filled_dib_.end());
82 }
83 79
84 // A list of mock methods. 80 // A list of mock methods.
85 MOCK_METHOD4(OnNewBufferCreated, 81 MOCK_METHOD4(OnNewBufferCreated,
86 void(int device_id, base::SharedMemoryHandle handle, 82 void(int device_id, base::SharedMemoryHandle handle,
87 int length, int buffer_id)); 83 int length, int buffer_id));
88 MOCK_METHOD3(OnBufferFilled, 84 MOCK_METHOD3(OnBufferFilled,
89 void(int device_id, int buffer_id, base::Time timestamp)); 85 void(int device_id, int buffer_id, base::Time timestamp));
90 MOCK_METHOD2(OnStateChanged, 86 MOCK_METHOD2(OnStateChanged,
91 void(int device_id, video_capture::State state)); 87 void(int device_id, video_capture::State state));
92 MOCK_METHOD1(OnDeviceInfo, void(int device_id)); 88 MOCK_METHOD1(OnDeviceInfo, void(int device_id));
93 89
94 // Use class DumpVideo to write I420 video to file. 90 // Use class DumpVideo to write I420 video to file.
95 void SetDumpVideo(bool enable) { 91 void SetDumpVideo(bool enable) {
96 dump_video_ = enable; 92 dump_video_ = enable;
97 } 93 }
94
98 void SetReturnReceviedDibs(bool enable) { 95 void SetReturnReceviedDibs(bool enable) {
99 return_buffers_ = enable; 96 return_buffers_ = enable;
100 } 97 }
101 98
102 // Return Dibs we currently have received. 99 // Return Dibs we currently have received.
103 void ReturnReceivedDibs(int device_id) { 100 void ReturnReceivedDibs(int device_id) {
104 int handle = GetReceivedDib(); 101 int handle = GetReceivedDib();
105 while (handle) { 102 while (handle) {
106 this->OnReceiveEmptyBuffer(device_id, handle); 103 this->OnReceiveEmptyBuffer(device_id, handle);
107 handle = GetReceivedDib(); 104 handle = GetReceivedDib();
108 } 105 }
109 } 106 }
107
110 int GetReceivedDib() { 108 int GetReceivedDib() {
111 if (filled_dib_.empty()) 109 if (filled_dib_.empty())
112 return 0; 110 return 0;
113 std::map<int, base::SharedMemory*>::iterator it = filled_dib_.begin(); 111 std::map<int, base::SharedMemory*>::iterator it = filled_dib_.begin();
114 int h = it->first; 112 int h = it->first;
115 delete it->second; 113 delete it->second;
116 filled_dib_.erase(it); 114 filled_dib_.erase(it);
117 115
118 return h; 116 return h;
119 } 117 }
120 118
121 private: 119 private:
120 virtual ~MockVideoCaptureHost() {
121 STLDeleteContainerPairSecondPointers(filled_dib_.begin(),
122 filled_dib_.end());
123 }
124
122 // This method is used to dispatch IPC messages to the renderer. We intercept 125 // This method is used to dispatch IPC messages to the renderer. We intercept
123 // these messages here and dispatch to our mock methods to verify the 126 // these messages here and dispatch to our mock methods to verify the
124 // conversation between this object and the renderer. 127 // conversation between this object and the renderer.
125 virtual bool Send(IPC::Message* message) { 128 virtual bool Send(IPC::Message* message) {
126 CHECK(message); 129 CHECK(message);
127 130
128 // In this method we dispatch the messages to the according handlers as if 131 // In this method we dispatch the messages to the according handlers as if
129 // we are the renderer. 132 // we are the renderer.
130 bool handled = true; 133 bool handled = true;
131 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureHost, *message) 134 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureHost, *message)
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 400 }
398 401
399 #ifdef DUMP_VIDEO 402 #ifdef DUMP_VIDEO
400 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { 403 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) {
401 CaptureAndDumpVideo(640, 480, 30); 404 CaptureAndDumpVideo(640, 480, 30);
402 } 405 }
403 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { 406 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) {
404 CaptureAndDumpVideo(1280, 720, 30); 407 CaptureAndDumpVideo(1280, 720, 30);
405 } 408 }
406 #endif 409 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698