Chromium Code Reviews| 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/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 expectation_->picker_created = true; | 49 expectation_->picker_created = true; |
| 50 } | 50 } |
| 51 ~FakeDesktopMediaPicker() override { expectation_->picker_deleted = true; } | 51 ~FakeDesktopMediaPicker() override { expectation_->picker_deleted = true; } |
| 52 | 52 |
| 53 // DesktopMediaPicker interface. | 53 // DesktopMediaPicker interface. |
| 54 void Show(content::WebContents* web_contents, | 54 void Show(content::WebContents* web_contents, |
| 55 gfx::NativeWindow context, | 55 gfx::NativeWindow context, |
| 56 gfx::NativeWindow parent, | 56 gfx::NativeWindow parent, |
| 57 const base::string16& app_name, | 57 const base::string16& app_name, |
| 58 const base::string16& target_name, | 58 const base::string16& target_name, |
| 59 std::unique_ptr<DesktopMediaList> model, | 59 std::unique_ptr<DesktopMediaList> screen_list, |
| 60 std::unique_ptr<DesktopMediaList> window_list, | |
| 61 std::unique_ptr<DesktopMediaList> tab_list, | |
| 60 bool request_audio, | 62 bool request_audio, |
| 61 const DoneCallback& done_callback) override { | 63 const DoneCallback& done_callback) override { |
| 62 if (!expectation_->cancelled) { | 64 if (!expectation_->cancelled) { |
| 63 // Post a task to call the callback asynchronously. | 65 // Post a task to call the callback asynchronously. |
| 64 base::ThreadTaskRunnerHandle::Get()->PostTask( | 66 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 65 FROM_HERE, | 67 FROM_HERE, |
| 66 base::Bind(&FakeDesktopMediaPicker::CallCallback, | 68 base::Bind(&FakeDesktopMediaPicker::CallCallback, |
| 67 weak_factory_.GetWeakPtr(), done_callback)); | 69 weak_factory_.GetWeakPtr(), done_callback)); |
| 68 } else { | 70 } else { |
| 69 // If we expect the dialog to be cancelled then store the callback to | 71 // If we expect the dialog to be cancelled then store the callback to |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 91 FakeDesktopMediaPickerFactory() {} | 93 FakeDesktopMediaPickerFactory() {} |
| 92 ~FakeDesktopMediaPickerFactory() override {} | 94 ~FakeDesktopMediaPickerFactory() override {} |
| 93 | 95 |
| 94 void SetTestFlags(TestFlags* test_flags, int tests_count) { | 96 void SetTestFlags(TestFlags* test_flags, int tests_count) { |
| 95 test_flags_ = test_flags; | 97 test_flags_ = test_flags; |
| 96 tests_count_ = tests_count; | 98 tests_count_ = tests_count; |
| 97 current_test_ = 0; | 99 current_test_ = 0; |
| 98 } | 100 } |
| 99 | 101 |
| 100 // DesktopCaptureChooseDesktopMediaFunction::PickerFactory interface. | 102 // DesktopCaptureChooseDesktopMediaFunction::PickerFactory interface. |
| 101 std::unique_ptr<DesktopMediaList> CreateModel(bool show_screens, | 103 std::vector<std::unique_ptr<DesktopMediaList>> CreateModel( |
| 102 bool show_windows, | 104 bool show_screens, |
| 103 bool show_tabs, | 105 bool show_windows, |
| 104 bool show_audio) override { | 106 bool show_tabs, |
| 107 bool show_audio) override { | |
| 105 EXPECT_LE(current_test_, tests_count_); | 108 EXPECT_LE(current_test_, tests_count_); |
| 106 if (current_test_ >= tests_count_) | 109 std::vector<std::unique_ptr<DesktopMediaList>> media_lists; |
| 107 return std::unique_ptr<DesktopMediaList>(); | 110 if (current_test_ >= tests_count_) { |
|
msw
2016/04/13 00:04:02
nit: just return the empty vector, if this is just
qiangchen
2016/04/14 17:08:40
media_lists here must have three items in it, othe
| |
| 111 media_lists.push_back(nullptr); | |
| 112 media_lists.push_back(nullptr); | |
| 113 media_lists.push_back(nullptr); | |
| 114 return media_lists; | |
| 115 } | |
| 108 EXPECT_EQ(test_flags_[current_test_].expect_screens, show_screens); | 116 EXPECT_EQ(test_flags_[current_test_].expect_screens, show_screens); |
| 109 EXPECT_EQ(test_flags_[current_test_].expect_windows, show_windows); | 117 EXPECT_EQ(test_flags_[current_test_].expect_windows, show_windows); |
| 110 EXPECT_EQ(test_flags_[current_test_].expect_tabs, show_tabs); | 118 EXPECT_EQ(test_flags_[current_test_].expect_tabs, show_tabs); |
| 111 EXPECT_EQ(test_flags_[current_test_].expect_audio, show_audio); | 119 EXPECT_EQ(test_flags_[current_test_].expect_audio, show_audio); |
| 112 return std::unique_ptr<DesktopMediaList>(new FakeDesktopMediaList()); | 120 |
| 121 media_lists.push_back(std::unique_ptr<DesktopMediaList>( | |
| 122 show_screens ? new FakeDesktopMediaList() : nullptr)); | |
| 123 media_lists.push_back(std::unique_ptr<DesktopMediaList>( | |
| 124 show_windows ? new FakeDesktopMediaList() : nullptr)); | |
| 125 media_lists.push_back(std::unique_ptr<DesktopMediaList>( | |
| 126 show_tabs ? new FakeDesktopMediaList() : nullptr)); | |
| 127 return media_lists; | |
| 113 } | 128 } |
| 114 | 129 |
| 115 std::unique_ptr<DesktopMediaPicker> CreatePicker() override { | 130 std::unique_ptr<DesktopMediaPicker> CreatePicker() override { |
| 116 EXPECT_LE(current_test_, tests_count_); | 131 EXPECT_LE(current_test_, tests_count_); |
| 117 if (current_test_ >= tests_count_) | 132 if (current_test_ >= tests_count_) |
| 118 return std::unique_ptr<DesktopMediaPicker>(); | 133 return std::unique_ptr<DesktopMediaPicker>(); |
| 119 ++current_test_; | 134 ++current_test_; |
| 120 return std::unique_ptr<DesktopMediaPicker>( | 135 return std::unique_ptr<DesktopMediaPicker>( |
| 121 new FakeDesktopMediaPicker(test_flags_ + current_test_ - 1)); | 136 new FakeDesktopMediaPicker(test_flags_ + current_test_ - 1)); |
| 122 } | 137 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 EXPECT_TRUE(result); | 287 EXPECT_TRUE(result); |
| 273 EXPECT_TRUE(test_flags[2].picker_created); | 288 EXPECT_TRUE(test_flags[2].picker_created); |
| 274 EXPECT_FALSE(test_flags[2].picker_deleted); | 289 EXPECT_FALSE(test_flags[2].picker_deleted); |
| 275 | 290 |
| 276 web_contents->Close(); | 291 web_contents->Close(); |
| 277 destroyed_watcher.Wait(); | 292 destroyed_watcher.Wait(); |
| 278 EXPECT_TRUE(test_flags[2].picker_deleted); | 293 EXPECT_TRUE(test_flags[2].picker_deleted); |
| 279 } | 294 } |
| 280 | 295 |
| 281 } // namespace extensions | 296 } // namespace extensions |
| OLD | NEW |