Chromium Code Reviews| 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" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 80 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 81 | 81 |
| 82 GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnFocus(); | 82 GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnFocus(); |
| 83 EXPECT_TRUE( | 83 EXPECT_TRUE( |
| 84 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 84 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 85 | 85 |
| 86 GetPickerDialogView()->GetDialogClientView()->AcceptWindow(); | 86 GetPickerDialogView()->GetDialogClientView()->AcceptWindow(); |
| 87 base::RunLoop().RunUntilIdle(); | 87 base::RunLoop().RunUntilIdle(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 // Verifies that cancel button click leads to dialog close without notify a | |
| 91 // selection of MediaSourceView. | |
|
Peter Kasting
2015/10/05 20:59:46
The comments in and around these new tests have gr
gyzhou
2015/10/05 21:12:27
This it the reason I asked Sergey to specially pay
| |
| 92 TEST_F(DesktopMediaPickerViewsTest, DoneCallbackCalledOnCancelButtonPressed) { | |
| 93 EXPECT_CALL(*this, OnPickerDone(content::DesktopMediaID())); | |
| 94 | |
| 95 const int kFakeId = 222; | |
| 96 media_list_->AddSource(kFakeId); | |
| 97 GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnFocus(); | |
| 98 | |
| 99 GetPickerDialogView()->GetDialogClientView()->CancelWindow(); | |
| 100 base::RunLoop().RunUntilIdle(); | |
| 101 } | |
| 102 | |
| 103 // Verifies that a MediaSourceView is selected with mouse left click and | |
| 104 // original selected MediaSourceView gets unselected. | |
| 105 TEST_F(DesktopMediaPickerViewsTest, SelectMediaSourceViewOnSingleClick) { | |
| 106 media_list_->AddSource(0); | |
| 107 media_list_->AddSource(1); | |
| 108 | |
| 109 DesktopMediaSourceView* source_view_0 = | |
| 110 GetPickerDialogView()->GetMediaSourceViewForTesting(0); | |
| 111 | |
| 112 DesktopMediaSourceView* source_view_1 = | |
| 113 GetPickerDialogView()->GetMediaSourceViewForTesting(1); | |
| 114 | |
| 115 // Both media source views are not selected initially. | |
| 116 EXPECT_FALSE(source_view_0->is_selected()); | |
| 117 EXPECT_FALSE(source_view_1->is_selected()); | |
| 118 | |
| 119 // Source view 0 is selected with mouse click. | |
| 120 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), | |
| 121 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); | |
| 122 | |
| 123 GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnMousePressed(press); | |
| 124 | |
| 125 EXPECT_TRUE(source_view_0->is_selected()); | |
| 126 EXPECT_FALSE(source_view_1->is_selected()); | |
| 127 | |
| 128 // Source view 1 is selected and source view 0 is unselected with mouse click. | |
| 129 GetPickerDialogView()->GetMediaSourceViewForTesting(1)->OnMousePressed(press); | |
| 130 | |
| 131 EXPECT_FALSE(source_view_0->is_selected()); | |
| 132 EXPECT_TRUE(source_view_1->is_selected()); | |
| 133 } | |
| 134 | |
| 90 TEST_F(DesktopMediaPickerViewsTest, DoneCallbackCalledOnDoubleClick) { | 135 TEST_F(DesktopMediaPickerViewsTest, DoneCallbackCalledOnDoubleClick) { |
| 91 const int kFakeId = 222; | 136 const int kFakeId = 222; |
| 92 EXPECT_CALL(*this, | 137 EXPECT_CALL(*this, |
| 93 OnPickerDone(content::DesktopMediaID( | 138 OnPickerDone(content::DesktopMediaID( |
| 94 content::DesktopMediaID::TYPE_WINDOW, kFakeId))); | 139 content::DesktopMediaID::TYPE_WINDOW, kFakeId))); |
| 95 | 140 |
| 96 media_list_->AddSource(kFakeId); | 141 media_list_->AddSource(kFakeId); |
| 97 | 142 |
| 98 ui::MouseEvent double_click(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), | 143 ui::MouseEvent double_click(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), |
| 99 ui::EventTimeForNow(), | 144 ui::EventTimeForNow(), |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 | 223 |
| 179 GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnFocus(); | 224 GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnFocus(); |
| 180 EXPECT_TRUE( | 225 EXPECT_TRUE( |
| 181 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 226 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 182 | 227 |
| 183 media_list_->RemoveSource(0); | 228 media_list_->RemoveSource(0); |
| 184 EXPECT_FALSE( | 229 EXPECT_FALSE( |
| 185 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 230 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 186 } | 231 } |
| 187 | 232 |
| 233 // Verifies that the MediaListView get the initial focus. | |
| 234 TEST_F(DesktopMediaPickerViewsTest, ListViewHasInitialFocus) { | |
| 235 EXPECT_TRUE(GetPickerDialogView()->GetMediaListViewForTesting()->HasFocus()); | |
| 236 } | |
| 237 | |
| 188 } // namespace views | 238 } // namespace views |
| OLD | NEW |