OLD | NEW |
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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/message_loop/message_loop.h" | |
10 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
11 #include "content/browser/browser_thread_impl.h" | |
12 #include "content/browser/renderer_host/media/media_stream_settings_requester.h" | 10 #include "content/browser/renderer_host/media/media_stream_settings_requester.h" |
13 #include "content/browser/renderer_host/media/media_stream_ui_controller.h" | 11 #include "content/browser/renderer_host/media/media_stream_ui_controller.h" |
14 #include "content/common/media/media_stream_options.h" | 12 #include "content/common/media/media_stream_options.h" |
15 #include "content/public/common/media_stream_request.h" | 13 #include "content/public/common/media_stream_request.h" |
| 14 #include "content/public/test/test_browser_thread_bundle.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
18 | 17 |
19 using testing::_; | 18 using testing::_; |
20 | 19 |
21 namespace content { | 20 namespace content { |
22 | 21 |
23 class MediaStreamDeviceUIControllerTest | 22 class MediaStreamDeviceUIControllerTest |
24 : public ::testing::Test, | 23 : public ::testing::Test, |
25 public SettingsRequester { | 24 public SettingsRequester { |
(...skipping 12 matching lines...) Expand all Loading... |
38 "mic_id", | 37 "mic_id", |
39 0, | 38 0, |
40 0)); | 39 0)); |
41 devices->push_back(MediaStreamDevice(MEDIA_DEVICE_VIDEO_CAPTURE, | 40 devices->push_back(MediaStreamDevice(MEDIA_DEVICE_VIDEO_CAPTURE, |
42 "camera", | 41 "camera", |
43 "camera_id")); | 42 "camera_id")); |
44 } | 43 } |
45 | 44 |
46 protected: | 45 protected: |
47 virtual void SetUp() { | 46 virtual void SetUp() { |
48 message_loop_.reset(new base::MessageLoopForIO); | |
49 ui_thread_.reset(new BrowserThreadImpl(BrowserThread::UI, | |
50 message_loop_.get())); | |
51 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, | |
52 message_loop_.get())); | |
53 ui_controller_.reset(new MediaStreamUIController(this)); | 47 ui_controller_.reset(new MediaStreamUIController(this)); |
54 } | 48 } |
55 | 49 |
56 virtual void TearDown() { base::RunLoop().RunUntilIdle(); } | 50 virtual void TearDown() { base::RunLoop().RunUntilIdle(); } |
57 | 51 |
58 void CreateDummyRequest(const std::string& label, bool audio, bool video) { | 52 void CreateDummyRequest(const std::string& label, bool audio, bool video) { |
59 int dummy_render_process_id = 1; | 53 int dummy_render_process_id = 1; |
60 int dummy_render_view_id = 1; | 54 int dummy_render_view_id = 1; |
61 StreamOptions components(audio, video ); | 55 StreamOptions components(audio, video ); |
62 GURL security_origin; | 56 GURL security_origin; |
63 ui_controller_->MakeUIRequest(label, | 57 ui_controller_->MakeUIRequest(label, |
64 dummy_render_process_id, | 58 dummy_render_process_id, |
65 dummy_render_view_id, | 59 dummy_render_view_id, |
66 components, | 60 components, |
67 security_origin, | 61 security_origin, |
68 MEDIA_GENERATE_STREAM, | 62 MEDIA_GENERATE_STREAM, |
69 std::string()); | 63 std::string()); |
70 } | 64 } |
71 | 65 |
72 std::unique_ptr<base::MessageLoop> message_loop_; | 66 TestBrowserThreadBundle thread_bundle_; |
73 std::unique_ptr<BrowserThreadImpl> ui_thread_; | |
74 std::unique_ptr<BrowserThreadImpl> io_thread_; | |
75 std::unique_ptr<MediaStreamUIController> ui_controller_; | 67 std::unique_ptr<MediaStreamUIController> ui_controller_; |
76 | 68 |
77 private: | 69 private: |
78 DISALLOW_COPY_AND_ASSIGN(MediaStreamDeviceUIControllerTest); | 70 DISALLOW_COPY_AND_ASSIGN(MediaStreamDeviceUIControllerTest); |
79 }; | 71 }; |
80 | 72 |
81 TEST_F(MediaStreamDeviceUIControllerTest, GenerateRequest) { | 73 TEST_F(MediaStreamDeviceUIControllerTest, GenerateRequest) { |
82 const std::string label = "dummy_label"; | 74 const std::string label = "dummy_label"; |
83 CreateDummyRequest(label, true, false); | 75 CreateDummyRequest(label, true, false); |
84 | 76 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 EXPECT_CALL(*this, DevicesAccepted(label_1, _)); | 151 EXPECT_CALL(*this, DevicesAccepted(label_1, _)); |
160 EXPECT_CALL(*this, DevicesAccepted(label_2, _)); | 152 EXPECT_CALL(*this, DevicesAccepted(label_2, _)); |
161 | 153 |
162 base::RunLoop().RunUntilIdle(); | 154 base::RunLoop().RunUntilIdle(); |
163 | 155 |
164 ui_controller_->NotifyUIIndicatorDevicesClosed(label_1); | 156 ui_controller_->NotifyUIIndicatorDevicesClosed(label_1); |
165 ui_controller_->NotifyUIIndicatorDevicesClosed(label_2); | 157 ui_controller_->NotifyUIIndicatorDevicesClosed(label_2); |
166 } | 158 } |
167 | 159 |
168 } // namespace content | 160 } // namespace content |
OLD | NEW |