OLD | NEW |
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 <queue> | 5 #include <queue> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "chrome/browser/extensions/api/desktop_capture/desktop_capture_api.h" | 10 #include "chrome/browser/extensions/api/desktop_capture/desktop_capture_api.h" |
11 #include "chrome/browser/extensions/extension_apitest.h" | 11 #include "chrome/browser/extensions/extension_apitest.h" |
12 #include "chrome/browser/media/desktop_media_picker.h" | 12 #include "chrome/browser/media/fake_desktop_media_list.h" |
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
14 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
17 #include "content/public/test/browser_test_utils.h" | 17 #include "content/public/test/browser_test_utils.h" |
18 #include "net/dns/mock_host_resolver.h" | 18 #include "net/dns/mock_host_resolver.h" |
19 #include "net/test/embedded_test_server/embedded_test_server.h" | 19 #include "net/test/embedded_test_server/embedded_test_server.h" |
20 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" | |
21 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h" | |
22 | 20 |
23 namespace extensions { | 21 namespace extensions { |
24 | 22 |
25 namespace { | 23 namespace { |
26 | 24 |
27 class FakeDesktopMediaPicker : public DesktopMediaPicker { | 25 class FakeDesktopMediaPicker : public DesktopMediaPicker { |
28 public: | 26 public: |
29 explicit FakeDesktopMediaPicker(const content::DesktopMediaID& source, | 27 explicit FakeDesktopMediaPicker(const content::DesktopMediaID& source, |
30 bool expect_cancelled) | 28 bool expect_cancelled) |
31 : source_(source), | 29 : source_(source), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 virtual ~FakeDesktopMediaPickerFactory() {} | 79 virtual ~FakeDesktopMediaPickerFactory() {} |
82 | 80 |
83 void SetExpectations(const Expectation* expectation_array, int size) { | 81 void SetExpectations(const Expectation* expectation_array, int size) { |
84 for (int i = 0; i < size; ++i) { | 82 for (int i = 0; i < size; ++i) { |
85 expectations_.push(expectation_array[i]); | 83 expectations_.push(expectation_array[i]); |
86 } | 84 } |
87 } | 85 } |
88 | 86 |
89 // DesktopCaptureChooseDesktopMediaFunction::PickerFactory interface. | 87 // DesktopCaptureChooseDesktopMediaFunction::PickerFactory interface. |
90 virtual scoped_ptr<DesktopMediaList> CreateModel( | 88 virtual scoped_ptr<DesktopMediaList> CreateModel( |
91 scoped_ptr<webrtc::ScreenCapturer> screen_capturer, | 89 bool show_screens, |
92 scoped_ptr<webrtc::WindowCapturer> window_capturer) OVERRIDE { | 90 bool show_windows) OVERRIDE { |
93 EXPECT_TRUE(!expectations_.empty()); | 91 EXPECT_TRUE(!expectations_.empty()); |
94 if (!expectations_.empty()) { | 92 if (!expectations_.empty()) { |
95 EXPECT_EQ(expectations_.front().screens, !!screen_capturer.get()); | 93 EXPECT_EQ(expectations_.front().screens, show_screens); |
96 EXPECT_EQ(expectations_.front().windows, !!window_capturer.get()); | 94 EXPECT_EQ(expectations_.front().windows, show_windows); |
97 } | 95 } |
98 return scoped_ptr<DesktopMediaList>(new NativeDesktopMediaList( | 96 return scoped_ptr<DesktopMediaList>(new FakeDesktopMediaList()); |
99 screen_capturer.Pass(), window_capturer.Pass())); | |
100 } | 97 } |
101 virtual scoped_ptr<DesktopMediaPicker> CreatePicker() OVERRIDE { | 98 virtual scoped_ptr<DesktopMediaPicker> CreatePicker() OVERRIDE { |
102 content::DesktopMediaID next_source; | 99 content::DesktopMediaID next_source; |
103 bool expect_cancelled = false; | 100 bool expect_cancelled = false; |
104 if (!expectations_.empty()) { | 101 if (!expectations_.empty()) { |
105 next_source = expectations_.front().selected_source; | 102 next_source = expectations_.front().selected_source; |
106 expect_cancelled = expectations_.front().cancelled; | 103 expect_cancelled = expectations_.front().cancelled; |
107 expectations_.pop(); | 104 expectations_.pop(); |
108 } | 105 } |
109 return scoped_ptr<DesktopMediaPicker>( | 106 return scoped_ptr<DesktopMediaPicker>( |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 "getStream()", &result)); | 220 "getStream()", &result)); |
224 EXPECT_TRUE(result); | 221 EXPECT_TRUE(result); |
225 | 222 |
226 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 223 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
227 browser()->tab_strip_model()->GetActiveWebContents(), | 224 browser()->tab_strip_model()->GetActiveWebContents(), |
228 "getStreamWithInvalidId()", &result)); | 225 "getStreamWithInvalidId()", &result)); |
229 EXPECT_TRUE(result); | 226 EXPECT_TRUE(result); |
230 } | 227 } |
231 | 228 |
232 } // namespace extensions | 229 } // namespace extensions |
OLD | NEW |