OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/views/desktop_media_picker_views.h" |
| 6 |
| 7 #include <utility> |
| 8 |
5 #include "base/bind.h" | 9 #include "base/bind.h" |
6 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
7 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/media/fake_desktop_media_list.h" | 12 #include "chrome/browser/media/fake_desktop_media_list.h" |
9 #include "chrome/browser/ui/views/desktop_media_picker_views.h" | |
10 #include "components/web_modal/test_web_contents_modal_dialog_host.h" | 13 #include "components/web_modal/test_web_contents_modal_dialog_host.h" |
11 #include "content/public/test/test_browser_thread_bundle.h" | 14 #include "content/public/test/test_browser_thread_bundle.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
15 #include "ui/events/event_utils.h" | 18 #include "ui/events/event_utils.h" |
16 #include "ui/views/test/scoped_views_test_helper.h" | 19 #include "ui/views/test/scoped_views_test_helper.h" |
17 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
18 #include "ui/views/window/dialog_client_view.h" | 21 #include "ui/views/window/dialog_client_view.h" |
19 #include "ui/views/window/dialog_delegate.h" | 22 #include "ui/views/window/dialog_delegate.h" |
20 | 23 |
21 namespace views { | 24 namespace views { |
22 | 25 |
23 class DesktopMediaPickerViewsTest : public testing::Test { | 26 class DesktopMediaPickerViewsTest : public testing::Test { |
24 public: | 27 public: |
25 DesktopMediaPickerViewsTest() {} | 28 DesktopMediaPickerViewsTest() {} |
26 ~DesktopMediaPickerViewsTest() override {} | 29 ~DesktopMediaPickerViewsTest() override {} |
27 | 30 |
28 void SetUp() override { | 31 void SetUp() override { |
29 media_list_ = new FakeDesktopMediaList(); | 32 media_list_ = new FakeDesktopMediaList(); |
30 scoped_ptr<FakeDesktopMediaList> media_list(media_list_); | 33 scoped_ptr<FakeDesktopMediaList> media_list(media_list_); |
31 | 34 |
32 base::string16 app_name = base::ASCIIToUTF16("foo"); | 35 base::string16 app_name = base::ASCIIToUTF16("foo"); |
33 | 36 |
34 picker_views_.reset(new DesktopMediaPickerViews()); | 37 picker_views_.reset(new DesktopMediaPickerViews()); |
35 picker_views_->Show(NULL, | 38 picker_views_->Show(NULL, test_helper_.GetContext(), NULL, app_name, |
36 test_helper_.GetContext(), | 39 app_name, std::move(media_list), |
37 NULL, | |
38 app_name, | |
39 app_name, | |
40 media_list.Pass(), | |
41 base::Bind(&DesktopMediaPickerViewsTest::OnPickerDone, | 40 base::Bind(&DesktopMediaPickerViewsTest::OnPickerDone, |
42 base::Unretained(this))); | 41 base::Unretained(this))); |
43 } | 42 } |
44 | 43 |
45 void TearDown() override { | 44 void TearDown() override { |
46 if (GetPickerDialogView()) { | 45 if (GetPickerDialogView()) { |
47 EXPECT_CALL(*this, OnPickerDone(content::DesktopMediaID())); | 46 EXPECT_CALL(*this, OnPickerDone(content::DesktopMediaID())); |
48 GetPickerDialogView()->GetWidget()->CloseNow(); | 47 GetPickerDialogView()->GetWidget()->CloseNow(); |
49 } | 48 } |
50 } | 49 } |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 EXPECT_FALSE( | 215 EXPECT_FALSE( |
217 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 216 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
218 } | 217 } |
219 | 218 |
220 // Verifies that the MediaListView get the initial focus. | 219 // Verifies that the MediaListView get the initial focus. |
221 TEST_F(DesktopMediaPickerViewsTest, ListViewHasInitialFocus) { | 220 TEST_F(DesktopMediaPickerViewsTest, ListViewHasInitialFocus) { |
222 EXPECT_TRUE(GetPickerDialogView()->GetMediaListViewForTesting()->HasFocus()); | 221 EXPECT_TRUE(GetPickerDialogView()->GetMediaListViewForTesting()->HasFocus()); |
223 } | 222 } |
224 | 223 |
225 } // namespace views | 224 } // namespace views |
OLD | NEW |