| 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" | 5 #include "chrome/browser/ui/views/desktop_media_picker_views.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 namespace views { | 24 namespace views { |
| 25 | 25 |
| 26 class DesktopMediaPickerViewsTest : public testing::Test { | 26 class DesktopMediaPickerViewsTest : public testing::Test { |
| 27 public: | 27 public: |
| 28 DesktopMediaPickerViewsTest() {} | 28 DesktopMediaPickerViewsTest() {} |
| 29 ~DesktopMediaPickerViewsTest() override {} | 29 ~DesktopMediaPickerViewsTest() override {} |
| 30 | 30 |
| 31 void SetUp() override { | 31 void SetUp() override { |
| 32 media_list_ = new FakeDesktopMediaList(); | 32 media_list_ = new FakeDesktopMediaList(); |
| 33 scoped_ptr<FakeDesktopMediaList> media_list(media_list_); | 33 std::unique_ptr<FakeDesktopMediaList> media_list(media_list_); |
| 34 | 34 |
| 35 base::string16 app_name = base::ASCIIToUTF16("foo"); | 35 base::string16 app_name = base::ASCIIToUTF16("foo"); |
| 36 | 36 |
| 37 picker_views_.reset(new DesktopMediaPickerViews()); | 37 picker_views_.reset(new DesktopMediaPickerViews()); |
| 38 picker_views_->Show(NULL, test_helper_.GetContext(), NULL, app_name, | 38 picker_views_->Show(NULL, test_helper_.GetContext(), NULL, app_name, |
| 39 app_name, std::move(media_list), false, | 39 app_name, std::move(media_list), false, |
| 40 base::Bind(&DesktopMediaPickerViewsTest::OnPickerDone, | 40 base::Bind(&DesktopMediaPickerViewsTest::OnPickerDone, |
| 41 base::Unretained(this))); | 41 base::Unretained(this))); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void TearDown() override { | 44 void TearDown() override { |
| 45 if (GetPickerDialogView()) { | 45 if (GetPickerDialogView()) { |
| 46 EXPECT_CALL(*this, OnPickerDone(content::DesktopMediaID())); | 46 EXPECT_CALL(*this, OnPickerDone(content::DesktopMediaID())); |
| 47 GetPickerDialogView()->GetWidget()->CloseNow(); | 47 GetPickerDialogView()->GetWidget()->CloseNow(); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 DesktopMediaPickerDialogView* GetPickerDialogView() const { | 51 DesktopMediaPickerDialogView* GetPickerDialogView() const { |
| 52 return picker_views_->GetDialogViewForTesting(); | 52 return picker_views_->GetDialogViewForTesting(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 MOCK_METHOD1(OnPickerDone, void(content::DesktopMediaID)); | 55 MOCK_METHOD1(OnPickerDone, void(content::DesktopMediaID)); |
| 56 | 56 |
| 57 protected: | 57 protected: |
| 58 content::TestBrowserThreadBundle thread_bundle_; | 58 content::TestBrowserThreadBundle thread_bundle_; |
| 59 views::ScopedViewsTestHelper test_helper_; | 59 views::ScopedViewsTestHelper test_helper_; |
| 60 FakeDesktopMediaList* media_list_; | 60 FakeDesktopMediaList* media_list_; |
| 61 scoped_ptr<DesktopMediaPickerViews> picker_views_; | 61 std::unique_ptr<DesktopMediaPickerViews> picker_views_; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 TEST_F(DesktopMediaPickerViewsTest, DoneCallbackCalledWhenWindowClosed) { | 64 TEST_F(DesktopMediaPickerViewsTest, DoneCallbackCalledWhenWindowClosed) { |
| 65 EXPECT_CALL(*this, OnPickerDone(content::DesktopMediaID())); | 65 EXPECT_CALL(*this, OnPickerDone(content::DesktopMediaID())); |
| 66 | 66 |
| 67 GetPickerDialogView()->GetWidget()->Close(); | 67 GetPickerDialogView()->GetWidget()->Close(); |
| 68 base::RunLoop().RunUntilIdle(); | 68 base::RunLoop().RunUntilIdle(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 TEST_F(DesktopMediaPickerViewsTest, DoneCallbackCalledOnOkButtonPressed) { | 71 TEST_F(DesktopMediaPickerViewsTest, DoneCallbackCalledOnOkButtonPressed) { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 EXPECT_FALSE( | 215 EXPECT_FALSE( |
| 216 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 216 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 217 } | 217 } |
| 218 | 218 |
| 219 // Verifies that the MediaListView get the initial focus. | 219 // Verifies that the MediaListView get the initial focus. |
| 220 TEST_F(DesktopMediaPickerViewsTest, ListViewHasInitialFocus) { | 220 TEST_F(DesktopMediaPickerViewsTest, ListViewHasInitialFocus) { |
| 221 EXPECT_TRUE(GetPickerDialogView()->GetMediaListViewForTesting()->HasFocus()); | 221 EXPECT_TRUE(GetPickerDialogView()->GetMediaListViewForTesting()->HasFocus()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 } // namespace views | 224 } // namespace views |
| OLD | NEW |