| 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/events/event_utils.h" | 16 #include "ui/events/event_utils.h" |
| 17 #include "ui/views/test/views_test_helper.h" | 17 #include "ui/views/test/views_test_helper.h" |
| 18 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 19 #include "ui/views/window/dialog_delegate.h" | 19 #include "ui/views/window/dialog_delegate.h" |
| 20 | 20 |
| 21 namespace views { | 21 namespace views { |
| 22 | 22 |
| 23 class DesktopMediaPickerViewsTest : public testing::Test { | 23 class DesktopMediaPickerViewsTest : public testing::Test { |
| 24 public: | 24 public: |
| 25 DesktopMediaPickerViewsTest() {} | 25 DesktopMediaPickerViewsTest() {} |
| 26 virtual ~DesktopMediaPickerViewsTest() {} | 26 ~DesktopMediaPickerViewsTest() override {} |
| 27 | 27 |
| 28 virtual void SetUp() override { | 28 void SetUp() override { |
| 29 bool enable_pixel_output = false; | 29 bool enable_pixel_output = false; |
| 30 ui::ContextFactory* context_factory = | 30 ui::ContextFactory* context_factory = |
| 31 ui::InitializeContextFactoryForTests(enable_pixel_output); | 31 ui::InitializeContextFactoryForTests(enable_pixel_output); |
| 32 test_helper_.reset( | 32 test_helper_.reset( |
| 33 ViewsTestHelper::Create(base::MessageLoopForUI::current(), | 33 ViewsTestHelper::Create(base::MessageLoopForUI::current(), |
| 34 context_factory)); | 34 context_factory)); |
| 35 test_helper_->SetUp(); | 35 test_helper_->SetUp(); |
| 36 | 36 |
| 37 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); | 37 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); |
| 38 params.context = test_helper_->GetContext(); | 38 params.context = test_helper_->GetContext(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 49 picker_views_->Show(NULL, | 49 picker_views_->Show(NULL, |
| 50 parent_widget_->GetNativeWindow(), | 50 parent_widget_->GetNativeWindow(), |
| 51 NULL, | 51 NULL, |
| 52 app_name, | 52 app_name, |
| 53 app_name, | 53 app_name, |
| 54 media_list.Pass(), | 54 media_list.Pass(), |
| 55 base::Bind(&DesktopMediaPickerViewsTest::OnPickerDone, | 55 base::Bind(&DesktopMediaPickerViewsTest::OnPickerDone, |
| 56 base::Unretained(this))); | 56 base::Unretained(this))); |
| 57 } | 57 } |
| 58 | 58 |
| 59 virtual void TearDown() override { | 59 void TearDown() override { |
| 60 test_helper_->TearDown(); | 60 test_helper_->TearDown(); |
| 61 ui::TerminateContextFactoryForTests(); | 61 ui::TerminateContextFactoryForTests(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 DesktopMediaPickerDialogView* GetPickerDialogView() const { | 64 DesktopMediaPickerDialogView* GetPickerDialogView() const { |
| 65 return picker_views_->GetDialogViewForTesting(); | 65 return picker_views_->GetDialogViewForTesting(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 MOCK_METHOD1(OnPickerDone, void(content::DesktopMediaID)); | 68 MOCK_METHOD1(OnPickerDone, void(content::DesktopMediaID)); |
| 69 | 69 |
| (...skipping 123 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 |