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 a MediaSourceView is selected with mouse left click and |
| 91 // original selected MediaSourceView gets unselected. |
| 92 TEST_F(DesktopMediaPickerViewsTest, SelectMediaSourceViewOnSingleClick) { |
| 93 media_list_->AddSource(0); |
| 94 media_list_->AddSource(1); |
| 95 |
| 96 DesktopMediaSourceView* source_view_0 = |
| 97 GetPickerDialogView()->GetMediaSourceViewForTesting(0); |
| 98 |
| 99 DesktopMediaSourceView* source_view_1 = |
| 100 GetPickerDialogView()->GetMediaSourceViewForTesting(1); |
| 101 |
| 102 // Both media source views are not selected initially. |
| 103 EXPECT_FALSE(source_view_0->is_selected()); |
| 104 EXPECT_FALSE(source_view_1->is_selected()); |
| 105 |
| 106 // Source view 0 is selected with mouse click. |
| 107 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), |
| 108 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); |
| 109 |
| 110 GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnMousePressed(press); |
| 111 |
| 112 EXPECT_TRUE(source_view_0->is_selected()); |
| 113 EXPECT_FALSE(source_view_1->is_selected()); |
| 114 |
| 115 // Source view 1 is selected and source view 0 is unselected with mouse click. |
| 116 GetPickerDialogView()->GetMediaSourceViewForTesting(1)->OnMousePressed(press); |
| 117 |
| 118 EXPECT_FALSE(source_view_0->is_selected()); |
| 119 EXPECT_TRUE(source_view_1->is_selected()); |
| 120 } |
| 121 |
90 TEST_F(DesktopMediaPickerViewsTest, DoneCallbackCalledOnDoubleClick) { | 122 TEST_F(DesktopMediaPickerViewsTest, DoneCallbackCalledOnDoubleClick) { |
91 const int kFakeId = 222; | 123 const int kFakeId = 222; |
92 EXPECT_CALL(*this, | 124 EXPECT_CALL(*this, |
93 OnPickerDone(content::DesktopMediaID( | 125 OnPickerDone(content::DesktopMediaID( |
94 content::DesktopMediaID::TYPE_WINDOW, kFakeId))); | 126 content::DesktopMediaID::TYPE_WINDOW, kFakeId))); |
95 | 127 |
96 media_list_->AddSource(kFakeId); | 128 media_list_->AddSource(kFakeId); |
97 | 129 |
98 ui::MouseEvent double_click(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), | 130 ui::MouseEvent double_click(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), |
99 ui::EventTimeForNow(), | 131 ui::EventTimeForNow(), |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 210 |
179 GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnFocus(); | 211 GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnFocus(); |
180 EXPECT_TRUE( | 212 EXPECT_TRUE( |
181 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 213 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
182 | 214 |
183 media_list_->RemoveSource(0); | 215 media_list_->RemoveSource(0); |
184 EXPECT_FALSE( | 216 EXPECT_FALSE( |
185 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 217 GetPickerDialogView()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
186 } | 218 } |
187 | 219 |
| 220 // Verifies that the MediaListView get the initial focus. |
| 221 TEST_F(DesktopMediaPickerViewsTest, ListViewHasInitialFocus) { |
| 222 EXPECT_TRUE(GetPickerDialogView()->GetMediaListViewForTesting()->HasFocus()); |
| 223 } |
| 224 |
188 } // namespace views | 225 } // namespace views |
OLD | NEW |