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

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

Issue 104653007: Renamed DesktopCaptureDeviceAsh to DesktopCaptureDeviceAura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 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/renderer_host/media/desktop_capture_device_ash.h" 5 #include "content/browser/renderer_host/media/desktop_capture_device_aura.h"
6 6
7 #include "base/synchronization/waitable_event.h" 7 #include "base/synchronization/waitable_event.h"
8 #include "content/browser/browser_thread_impl.h" 8 #include "content/browser/browser_thread_impl.h"
9 #include "media/video/capture/video_capture_types.h" 9 #include "media/video/capture/video_capture_types.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/aura/client/window_tree_client.h" 12 #include "ui/aura/client/window_tree_client.h"
13 #include "ui/aura/test/aura_test_helper.h" 13 #include "ui/aura/test/aura_test_helper.h"
14 #include "ui/aura/test/test_window_delegate.h" 14 #include "ui/aura/test/test_window_delegate.h"
15 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
(...skipping 26 matching lines...) Expand all
42 const media::VideoCaptureFormat& frame_format)); 42 const media::VideoCaptureFormat& frame_format));
43 MOCK_METHOD5(OnIncomingCapturedBuffer, 43 MOCK_METHOD5(OnIncomingCapturedBuffer,
44 void(const scoped_refptr<Buffer>& buffer, 44 void(const scoped_refptr<Buffer>& buffer,
45 media::VideoFrame::Format format, 45 media::VideoFrame::Format format,
46 const gfx::Size& dimensions, 46 const gfx::Size& dimensions,
47 base::Time timestamp, 47 base::Time timestamp,
48 int frame_rate)); 48 int frame_rate));
49 }; 49 };
50 50
51 // Test harness that sets up a minimal environment with necessary stubs. 51 // Test harness that sets up a minimal environment with necessary stubs.
52 class DesktopCaptureDeviceAshTest : public testing::Test { 52 class DesktopCaptureDeviceAuraTest : public testing::Test {
53 public: 53 public:
54 DesktopCaptureDeviceAshTest() 54 DesktopCaptureDeviceAuraTest()
55 : browser_thread_for_ui_(BrowserThread::UI, &message_loop_) {} 55 : browser_thread_for_ui_(BrowserThread::UI, &message_loop_) {}
56 virtual ~DesktopCaptureDeviceAshTest() {} 56 virtual ~DesktopCaptureDeviceAuraTest() {}
57 57
58 protected: 58 protected:
59 virtual void SetUp() OVERRIDE { 59 virtual void SetUp() OVERRIDE {
60 helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); 60 helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
61 helper_->SetUp(); 61 helper_->SetUp();
62 62
63 // We need a window to cover desktop area so that DesktopCaptureDeviceAsh 63 // We need a window to cover desktop area so that DesktopCaptureDeviceAura
64 // can use gfx::NativeWindow::GetWindowAtScreenPoint() to locate the 64 // can use gfx::NativeWindow::GetWindowAtScreenPoint() to locate the
65 // root window associated with the primary display. 65 // root window associated with the primary display.
66 gfx::Rect desktop_bounds = root_window()->bounds(); 66 gfx::Rect desktop_bounds = root_window()->bounds();
67 window_delegate_.reset(new aura::test::TestWindowDelegate()); 67 window_delegate_.reset(new aura::test::TestWindowDelegate());
68 desktop_window_.reset(new aura::Window(window_delegate_.get())); 68 desktop_window_.reset(new aura::Window(window_delegate_.get()));
69 desktop_window_->Init(ui::LAYER_TEXTURED); 69 desktop_window_->Init(ui::LAYER_TEXTURED);
70 desktop_window_->SetBounds(desktop_bounds); 70 desktop_window_->SetBounds(desktop_bounds);
71 aura::client::ParentWindowWithContext( 71 aura::client::ParentWindowWithContext(
72 desktop_window_.get(), root_window(), desktop_bounds); 72 desktop_window_.get(), root_window(), desktop_bounds);
73 desktop_window_->Show(); 73 desktop_window_->Show();
74 } 74 }
75 75
76 virtual void TearDown() OVERRIDE { 76 virtual void TearDown() OVERRIDE {
77 helper_->RunAllPendingInMessageLoop(); 77 helper_->RunAllPendingInMessageLoop();
78 root_window()->RemoveChild(desktop_window_.get()); 78 root_window()->RemoveChild(desktop_window_.get());
79 desktop_window_.reset(); 79 desktop_window_.reset();
80 window_delegate_.reset(); 80 window_delegate_.reset();
81 helper_->TearDown(); 81 helper_->TearDown();
82 } 82 }
83 83
84 aura::Window* root_window() { return helper_->root_window(); } 84 aura::Window* root_window() { return helper_->root_window(); }
85 85
86 private: 86 private:
87 base::MessageLoopForUI message_loop_; 87 base::MessageLoopForUI message_loop_;
88 BrowserThreadImpl browser_thread_for_ui_; 88 BrowserThreadImpl browser_thread_for_ui_;
89 scoped_ptr<aura::test::AuraTestHelper> helper_; 89 scoped_ptr<aura::test::AuraTestHelper> helper_;
90 scoped_ptr<aura::Window> desktop_window_; 90 scoped_ptr<aura::Window> desktop_window_;
91 scoped_ptr<aura::test::TestWindowDelegate> window_delegate_; 91 scoped_ptr<aura::test::TestWindowDelegate> window_delegate_;
92 92
93 DISALLOW_COPY_AND_ASSIGN(DesktopCaptureDeviceAshTest); 93 DISALLOW_COPY_AND_ASSIGN(DesktopCaptureDeviceAuraTest);
94 }; 94 };
95 95
96 TEST_F(DesktopCaptureDeviceAshTest, StartAndStop) { 96 TEST_F(DesktopCaptureDeviceAuraTest, StartAndStop) {
97 DesktopMediaID source(DesktopMediaID::TYPE_SCREEN, 0); 97 DesktopMediaID source(DesktopMediaID::TYPE_SCREEN, 0);
98 scoped_ptr<media::VideoCaptureDevice> capture_device( 98 scoped_ptr<media::VideoCaptureDevice> capture_device(
99 DesktopCaptureDeviceAsh::Create(source)); 99 DesktopCaptureDeviceAura::Create(source));
100 100
101 scoped_ptr<MockDeviceClient> client(new MockDeviceClient()); 101 scoped_ptr<MockDeviceClient> client(new MockDeviceClient());
102 EXPECT_CALL(*client, OnError()).Times(0); 102 EXPECT_CALL(*client, OnError()).Times(0);
103 103
104 media::VideoCaptureParams capture_params; 104 media::VideoCaptureParams capture_params;
105 capture_params.requested_format.frame_size.SetSize(640, 480); 105 capture_params.requested_format.frame_size.SetSize(640, 480);
106 capture_params.requested_format.frame_rate = kFrameRate; 106 capture_params.requested_format.frame_rate = kFrameRate;
107 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; 107 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
108 capture_params.allow_resolution_change = false; 108 capture_params.allow_resolution_change = false;
109 capture_device->AllocateAndStart( 109 capture_device->AllocateAndStart(
110 capture_params, client.PassAs<media::VideoCaptureDevice::Client>()); 110 capture_params, client.PassAs<media::VideoCaptureDevice::Client>());
111 capture_device->StopAndDeAllocate(); 111 capture_device->StopAndDeAllocate();
112 } 112 }
113 113
114 } // namespace 114 } // namespace
115 } // namespace content 115 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698