| 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 scoped_ptr<DesktopMediaList> model, | 59 std::unique_ptr<DesktopMediaList> model, |
| 60 bool request_audio, | 60 bool request_audio, |
| 61 const DoneCallback& done_callback) override { | 61 const DoneCallback& done_callback) override { |
| 62 if (!expectation_->cancelled) { | 62 if (!expectation_->cancelled) { |
| 63 // Post a task to call the callback asynchronously. | 63 // Post a task to call the callback asynchronously. |
| 64 base::ThreadTaskRunnerHandle::Get()->PostTask( | 64 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 65 FROM_HERE, | 65 FROM_HERE, |
| 66 base::Bind(&FakeDesktopMediaPicker::CallCallback, | 66 base::Bind(&FakeDesktopMediaPicker::CallCallback, |
| 67 weak_factory_.GetWeakPtr(), done_callback)); | 67 weak_factory_.GetWeakPtr(), done_callback)); |
| 68 } else { | 68 } else { |
| 69 // If we expect the dialog to be cancelled then store the callback to | 69 // If we expect the dialog to be cancelled then store the callback to |
| (...skipping 21 matching lines...) Expand all Loading... |
| 91 FakeDesktopMediaPickerFactory() {} | 91 FakeDesktopMediaPickerFactory() {} |
| 92 ~FakeDesktopMediaPickerFactory() override {} | 92 ~FakeDesktopMediaPickerFactory() override {} |
| 93 | 93 |
| 94 void SetTestFlags(TestFlags* test_flags, int tests_count) { | 94 void SetTestFlags(TestFlags* test_flags, int tests_count) { |
| 95 test_flags_ = test_flags; | 95 test_flags_ = test_flags; |
| 96 tests_count_ = tests_count; | 96 tests_count_ = tests_count; |
| 97 current_test_ = 0; | 97 current_test_ = 0; |
| 98 } | 98 } |
| 99 | 99 |
| 100 // DesktopCaptureChooseDesktopMediaFunction::PickerFactory interface. | 100 // DesktopCaptureChooseDesktopMediaFunction::PickerFactory interface. |
| 101 scoped_ptr<DesktopMediaList> CreateModel(bool show_screens, | 101 std::unique_ptr<DesktopMediaList> CreateModel(bool show_screens, |
| 102 bool show_windows, | 102 bool show_windows, |
| 103 bool show_tabs, | 103 bool show_tabs, |
| 104 bool show_audio) override { | 104 bool show_audio) override { |
| 105 EXPECT_LE(current_test_, tests_count_); | 105 EXPECT_LE(current_test_, tests_count_); |
| 106 if (current_test_ >= tests_count_) | 106 if (current_test_ >= tests_count_) |
| 107 return scoped_ptr<DesktopMediaList>(); | 107 return std::unique_ptr<DesktopMediaList>(); |
| 108 EXPECT_EQ(test_flags_[current_test_].expect_screens, show_screens); | 108 EXPECT_EQ(test_flags_[current_test_].expect_screens, show_screens); |
| 109 EXPECT_EQ(test_flags_[current_test_].expect_windows, show_windows); | 109 EXPECT_EQ(test_flags_[current_test_].expect_windows, show_windows); |
| 110 EXPECT_EQ(test_flags_[current_test_].expect_tabs, show_tabs); | 110 EXPECT_EQ(test_flags_[current_test_].expect_tabs, show_tabs); |
| 111 EXPECT_EQ(test_flags_[current_test_].expect_audio, show_audio); | 111 EXPECT_EQ(test_flags_[current_test_].expect_audio, show_audio); |
| 112 return scoped_ptr<DesktopMediaList>(new FakeDesktopMediaList()); | 112 return std::unique_ptr<DesktopMediaList>(new FakeDesktopMediaList()); |
| 113 } | 113 } |
| 114 | 114 |
| 115 scoped_ptr<DesktopMediaPicker> CreatePicker() override { | 115 std::unique_ptr<DesktopMediaPicker> CreatePicker() override { |
| 116 EXPECT_LE(current_test_, tests_count_); | 116 EXPECT_LE(current_test_, tests_count_); |
| 117 if (current_test_ >= tests_count_) | 117 if (current_test_ >= tests_count_) |
| 118 return scoped_ptr<DesktopMediaPicker>(); | 118 return std::unique_ptr<DesktopMediaPicker>(); |
| 119 ++current_test_; | 119 ++current_test_; |
| 120 return scoped_ptr<DesktopMediaPicker>( | 120 return std::unique_ptr<DesktopMediaPicker>( |
| 121 new FakeDesktopMediaPicker(test_flags_ + current_test_ - 1)); | 121 new FakeDesktopMediaPicker(test_flags_ + current_test_ - 1)); |
| 122 } | 122 } |
| 123 | 123 |
| 124 private: | 124 private: |
| 125 TestFlags* test_flags_; | 125 TestFlags* test_flags_; |
| 126 int tests_count_; | 126 int tests_count_; |
| 127 int current_test_; | 127 int current_test_; |
| 128 | 128 |
| 129 DISALLOW_COPY_AND_ASSIGN(FakeDesktopMediaPickerFactory); | 129 DISALLOW_COPY_AND_ASSIGN(FakeDesktopMediaPickerFactory); |
| 130 }; | 130 }; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 EXPECT_TRUE(result); | 272 EXPECT_TRUE(result); |
| 273 EXPECT_TRUE(test_flags[2].picker_created); | 273 EXPECT_TRUE(test_flags[2].picker_created); |
| 274 EXPECT_FALSE(test_flags[2].picker_deleted); | 274 EXPECT_FALSE(test_flags[2].picker_deleted); |
| 275 | 275 |
| 276 web_contents->Close(); | 276 web_contents->Close(); |
| 277 destroyed_watcher.Wait(); | 277 destroyed_watcher.Wait(); |
| 278 EXPECT_TRUE(test_flags[2].picker_deleted); | 278 EXPECT_TRUE(test_flags[2].picker_deleted); |
| 279 } | 279 } |
| 280 | 280 |
| 281 } // namespace extensions | 281 } // namespace extensions |
| OLD | NEW |