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" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 expectation_->picker_deleted = true; | 46 expectation_->picker_deleted = true; |
47 } | 47 } |
48 | 48 |
49 // DesktopMediaPicker interface. | 49 // DesktopMediaPicker interface. |
50 virtual void Show(content::WebContents* web_contents, | 50 virtual void Show(content::WebContents* web_contents, |
51 gfx::NativeWindow context, | 51 gfx::NativeWindow context, |
52 gfx::NativeWindow parent, | 52 gfx::NativeWindow parent, |
53 const base::string16& app_name, | 53 const base::string16& app_name, |
54 const base::string16& target_name, | 54 const base::string16& target_name, |
55 scoped_ptr<DesktopMediaList> model, | 55 scoped_ptr<DesktopMediaList> model, |
56 const DoneCallback& done_callback) OVERRIDE { | 56 const DoneCallback& done_callback) override { |
57 if (!expectation_->cancelled) { | 57 if (!expectation_->cancelled) { |
58 // Post a task to call the callback asynchronously. | 58 // Post a task to call the callback asynchronously. |
59 base::ThreadTaskRunnerHandle::Get()->PostTask( | 59 base::ThreadTaskRunnerHandle::Get()->PostTask( |
60 FROM_HERE, | 60 FROM_HERE, |
61 base::Bind(&FakeDesktopMediaPicker::CallCallback, | 61 base::Bind(&FakeDesktopMediaPicker::CallCallback, |
62 weak_factory_.GetWeakPtr(), done_callback)); | 62 weak_factory_.GetWeakPtr(), done_callback)); |
63 } else { | 63 } else { |
64 // If we expect the dialog to be cancelled then store the callback to | 64 // If we expect the dialog to be cancelled then store the callback to |
65 // retain reference to the callback handler. | 65 // retain reference to the callback handler. |
66 done_callback_ = done_callback; | 66 done_callback_ = done_callback; |
(...skipping 21 matching lines...) Expand all Loading... |
88 | 88 |
89 void SetTestFlags(TestFlags* test_flags, int tests_count) { | 89 void SetTestFlags(TestFlags* test_flags, int tests_count) { |
90 test_flags_ = test_flags; | 90 test_flags_ = test_flags; |
91 tests_count_ = tests_count; | 91 tests_count_ = tests_count; |
92 current_test_ = 0; | 92 current_test_ = 0; |
93 } | 93 } |
94 | 94 |
95 // DesktopCaptureChooseDesktopMediaFunction::PickerFactory interface. | 95 // DesktopCaptureChooseDesktopMediaFunction::PickerFactory interface. |
96 virtual scoped_ptr<DesktopMediaList> CreateModel( | 96 virtual scoped_ptr<DesktopMediaList> CreateModel( |
97 bool show_screens, | 97 bool show_screens, |
98 bool show_windows) OVERRIDE { | 98 bool show_windows) override { |
99 EXPECT_LE(current_test_, tests_count_); | 99 EXPECT_LE(current_test_, tests_count_); |
100 if (current_test_ >= tests_count_) | 100 if (current_test_ >= tests_count_) |
101 return scoped_ptr<DesktopMediaList>(); | 101 return scoped_ptr<DesktopMediaList>(); |
102 EXPECT_EQ(test_flags_[current_test_].expect_screens, show_screens); | 102 EXPECT_EQ(test_flags_[current_test_].expect_screens, show_screens); |
103 EXPECT_EQ(test_flags_[current_test_].expect_windows, show_windows); | 103 EXPECT_EQ(test_flags_[current_test_].expect_windows, show_windows); |
104 return scoped_ptr<DesktopMediaList>(new FakeDesktopMediaList()); | 104 return scoped_ptr<DesktopMediaList>(new FakeDesktopMediaList()); |
105 } | 105 } |
106 | 106 |
107 virtual scoped_ptr<DesktopMediaPicker> CreatePicker() OVERRIDE { | 107 virtual scoped_ptr<DesktopMediaPicker> CreatePicker() override { |
108 EXPECT_LE(current_test_, tests_count_); | 108 EXPECT_LE(current_test_, tests_count_); |
109 if (current_test_ >= tests_count_) | 109 if (current_test_ >= tests_count_) |
110 return scoped_ptr<DesktopMediaPicker>(); | 110 return scoped_ptr<DesktopMediaPicker>(); |
111 ++current_test_; | 111 ++current_test_; |
112 return scoped_ptr<DesktopMediaPicker>( | 112 return scoped_ptr<DesktopMediaPicker>( |
113 new FakeDesktopMediaPicker(test_flags_ + current_test_ - 1)); | 113 new FakeDesktopMediaPicker(test_flags_ + current_test_ - 1)); |
114 } | 114 } |
115 | 115 |
116 private: | 116 private: |
117 TestFlags* test_flags_; | 117 TestFlags* test_flags_; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 EXPECT_TRUE(result); | 234 EXPECT_TRUE(result); |
235 EXPECT_TRUE(test_flags[2].picker_created); | 235 EXPECT_TRUE(test_flags[2].picker_created); |
236 EXPECT_FALSE(test_flags[2].picker_deleted); | 236 EXPECT_FALSE(test_flags[2].picker_deleted); |
237 | 237 |
238 web_contents->Close(); | 238 web_contents->Close(); |
239 destroyed_watcher.Wait(); | 239 destroyed_watcher.Wait(); |
240 EXPECT_TRUE(test_flags[2].picker_deleted); | 240 EXPECT_TRUE(test_flags[2].picker_deleted); |
241 } | 241 } |
242 | 242 |
243 } // namespace extensions | 243 } // namespace extensions |
OLD | NEW |