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

Side by Side Diff: content/browser/media/capture/desktop_capture_device_aura_unittest.cc

Issue 2673373003: getUserMeida: report device starting states (Closed)
Patch Set: address comments on PS#8 Created 3 years, 9 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/browser/media/capture/desktop_capture_device_aura.h" 5 #include "content/browser/media/capture/desktop_capture_device_aura.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
14 #include "content/public/browser/desktop_media_id.h" 14 #include "content/public/browser/desktop_media_id.h"
15 #include "content/public/test/test_browser_thread_bundle.h" 15 #include "content/public/test/test_browser_thread_bundle.h"
16 #include "media/capture/video_capture_types.h" 16 #include "media/capture/video_capture_types.h"
17 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "ui/aura/client/window_parenting_client.h" 19 #include "ui/aura/client/window_parenting_client.h"
20 #include "ui/aura/test/aura_test_helper.h" 20 #include "ui/aura/test/aura_test_helper.h"
21 #include "ui/aura/test/test_window_delegate.h" 21 #include "ui/aura/test/test_window_delegate.h"
22 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
23 #include "ui/compositor/test/context_factories_for_test.h" 23 #include "ui/compositor/test/context_factories_for_test.h"
24 #include "ui/wm/core/default_activation_client.h" 24 #include "ui/wm/core/default_activation_client.h"
25 25
26 using ::testing::_; 26 using ::testing::_;
27 using ::testing::AnyNumber; 27 using ::testing::AnyNumber;
28 using ::testing::AtMost;
28 using ::testing::DoAll; 29 using ::testing::DoAll;
29 using ::testing::Expectation; 30 using ::testing::Expectation;
30 using ::testing::InvokeWithoutArgs; 31 using ::testing::InvokeWithoutArgs;
31 using ::testing::SaveArg; 32 using ::testing::SaveArg;
32 33
33 namespace media { 34 namespace media {
34 class VideoFrame; 35 class VideoFrame;
35 } // namespace media 36 } // namespace media
36 37
37 namespace content { 38 namespace content {
(...skipping 11 matching lines...) Expand all
49 base::TimeTicks reference_time, 50 base::TimeTicks reference_time,
50 base::TimeDelta tiemstamp, 51 base::TimeDelta tiemstamp,
51 int frame_feedback_id)); 52 int frame_feedback_id));
52 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); 53 MOCK_METHOD0(DoReserveOutputBuffer, void(void));
53 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); 54 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void));
54 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); 55 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void));
55 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void)); 56 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void));
56 MOCK_METHOD2(OnError, 57 MOCK_METHOD2(OnError,
57 void(const tracked_objects::Location& from_here, 58 void(const tracked_objects::Location& from_here,
58 const std::string& reason)); 59 const std::string& reason));
60 MOCK_METHOD0(OnStarted, void(void));
59 61
60 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>. 62 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>.
61 Buffer ReserveOutputBuffer(const gfx::Size& dimensions, 63 Buffer ReserveOutputBuffer(const gfx::Size& dimensions,
62 media::VideoPixelFormat format, 64 media::VideoPixelFormat format,
63 media::VideoPixelStorage storage, 65 media::VideoPixelStorage storage,
64 int frame_feedback_id) override { 66 int frame_feedback_id) override {
65 EXPECT_EQ(media::PIXEL_FORMAT_I420, format); 67 EXPECT_EQ(media::PIXEL_FORMAT_I420, format);
66 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage); 68 EXPECT_EQ(media::PIXEL_STORAGE_CPU, storage);
67 DoReserveOutputBuffer(); 69 DoReserveOutputBuffer();
68 return Buffer(); 70 return Buffer();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 150
149 TEST_F(DesktopCaptureDeviceAuraTest, StartAndStop) { 151 TEST_F(DesktopCaptureDeviceAuraTest, StartAndStop) {
150 std::unique_ptr<media::VideoCaptureDevice> capture_device = 152 std::unique_ptr<media::VideoCaptureDevice> capture_device =
151 DesktopCaptureDeviceAura::Create( 153 DesktopCaptureDeviceAura::Create(
152 content::DesktopMediaID::RegisterAuraWindow( 154 content::DesktopMediaID::RegisterAuraWindow(
153 content::DesktopMediaID::TYPE_SCREEN, root_window())); 155 content::DesktopMediaID::TYPE_SCREEN, root_window()));
154 ASSERT_TRUE(capture_device); 156 ASSERT_TRUE(capture_device);
155 157
156 std::unique_ptr<MockDeviceClient> client(new MockDeviceClient()); 158 std::unique_ptr<MockDeviceClient> client(new MockDeviceClient());
157 EXPECT_CALL(*client, OnError(_, _)).Times(0); 159 EXPECT_CALL(*client, OnError(_, _)).Times(0);
160 // |STARTED| is reported asynchronously, which may not be received if capture
161 // is stopped immediately.
162 EXPECT_CALL(*client, OnStarted()).Times(AtMost(1));
158 163
159 media::VideoCaptureParams capture_params; 164 media::VideoCaptureParams capture_params;
160 capture_params.requested_format.frame_size.SetSize(640, 480); 165 capture_params.requested_format.frame_size.SetSize(640, 480);
161 capture_params.requested_format.frame_rate = kFrameRate; 166 capture_params.requested_format.frame_rate = kFrameRate;
162 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; 167 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
163 capture_device->AllocateAndStart(capture_params, std::move(client)); 168 capture_device->AllocateAndStart(capture_params, std::move(client));
164 capture_device->StopAndDeAllocate(); 169 capture_device->StopAndDeAllocate();
165 } 170 }
166 171
167 } // namespace 172 } // namespace
168 } // namespace content 173 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698