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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/media/fake_desktop_media_list.h" | 8 #include "chrome/browser/media/fake_desktop_media_list.h" |
9 #include "chrome/browser/ui/views/desktop_media_picker_views.h" | 9 #include "chrome/browser/ui/views/desktop_media_picker_views.h" |
10 #include "components/web_modal/test_web_contents_modal_dialog_host.h" | 10 #include "components/web_modal/test_web_contents_modal_dialog_host.h" |
11 #include "content/public/test/test_browser_thread_bundle.h" | 11 #include "content/public/test/test_browser_thread_bundle.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
15 #include "ui/compositor/test/context_factories_for_test.h" | 15 #include "ui/compositor/test/context_factories_for_test.h" |
16 #include "ui/views/test/views_test_helper.h" | 16 #include "ui/views/test/views_test_helper.h" |
17 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
18 #include "ui/views/window/dialog_delegate.h" | 18 #include "ui/views/window/dialog_delegate.h" |
19 | 19 |
20 namespace views { | 20 namespace views { |
21 | 21 |
22 class DesktopMediaPickerViewsTest : public testing::Test { | 22 class DesktopMediaPickerViewsTest : public testing::Test { |
23 public: | 23 public: |
24 DesktopMediaPickerViewsTest() {} | 24 DesktopMediaPickerViewsTest() {} |
25 virtual ~DesktopMediaPickerViewsTest() {} | 25 virtual ~DesktopMediaPickerViewsTest() {} |
26 | 26 |
27 virtual void SetUp() OVERRIDE { | 27 virtual void SetUp() override { |
28 bool enable_pixel_output = false; | 28 bool enable_pixel_output = false; |
29 ui::ContextFactory* context_factory = | 29 ui::ContextFactory* context_factory = |
30 ui::InitializeContextFactoryForTests(enable_pixel_output); | 30 ui::InitializeContextFactoryForTests(enable_pixel_output); |
31 test_helper_.reset( | 31 test_helper_.reset( |
32 ViewsTestHelper::Create(base::MessageLoopForUI::current(), | 32 ViewsTestHelper::Create(base::MessageLoopForUI::current(), |
33 context_factory)); | 33 context_factory)); |
34 test_helper_->SetUp(); | 34 test_helper_->SetUp(); |
35 | 35 |
36 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); | 36 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); |
37 params.context = test_helper_->GetContext(); | 37 params.context = test_helper_->GetContext(); |
(...skipping 10 matching lines...) Expand all Loading... |
48 picker_views_->Show(NULL, | 48 picker_views_->Show(NULL, |
49 parent_widget_->GetNativeWindow(), | 49 parent_widget_->GetNativeWindow(), |
50 NULL, | 50 NULL, |
51 app_name, | 51 app_name, |
52 app_name, | 52 app_name, |
53 media_list.PassAs<DesktopMediaList>(), | 53 media_list.PassAs<DesktopMediaList>(), |
54 base::Bind(&DesktopMediaPickerViewsTest::OnPickerDone, | 54 base::Bind(&DesktopMediaPickerViewsTest::OnPickerDone, |
55 base::Unretained(this))); | 55 base::Unretained(this))); |
56 } | 56 } |
57 | 57 |
58 virtual void TearDown() OVERRIDE { | 58 virtual void TearDown() override { |
59 test_helper_->TearDown(); | 59 test_helper_->TearDown(); |
60 ui::TerminateContextFactoryForTests(); | 60 ui::TerminateContextFactoryForTests(); |
61 } | 61 } |
62 | 62 |
63 DesktopMediaPickerDialogView* GetPickerDialogView() const { | 63 DesktopMediaPickerDialogView* GetPickerDialogView() const { |
64 return picker_views_->GetDialogViewForTesting(); | 64 return picker_views_->GetDialogViewForTesting(); |
65 } | 65 } |
66 | 66 |
67 MOCK_METHOD1(OnPickerDone, void(content::DesktopMediaID)); | 67 MOCK_METHOD1(OnPickerDone, void(content::DesktopMediaID)); |
68 | 68 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnFocus(); | 193 GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnFocus(); |
194 EXPECT_TRUE( | 194 EXPECT_TRUE( |
195 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 195 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
196 | 196 |
197 media_list_->RemoveSource(0); | 197 media_list_->RemoveSource(0); |
198 EXPECT_FALSE( | 198 EXPECT_FALSE( |
199 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 199 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
200 } | 200 } |
201 | 201 |
202 } // namespace views | 202 } // namespace views |
OLD | NEW |