| 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_capture/desktop_media_picker_views.h" | 5 #include "chrome/browser/ui/views/desktop_capture/desktop_media_picker_views.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 DesktopMediaSourceView* source_view_1 = | 143 DesktopMediaSourceView* source_view_1 = |
| 144 GetPickerDialogView()->GetMediaSourceViewForTesting(1); | 144 GetPickerDialogView()->GetMediaSourceViewForTesting(1); |
| 145 | 145 |
| 146 // By default, the first screen is selected, but not for other sharing | 146 // By default, the first screen is selected, but not for other sharing |
| 147 // types. | 147 // types. |
| 148 EXPECT_EQ(source_type == DesktopMediaID::TYPE_SCREEN, | 148 EXPECT_EQ(source_type == DesktopMediaID::TYPE_SCREEN, |
| 149 source_view_0->is_selected()); | 149 source_view_0->is_selected()); |
| 150 EXPECT_FALSE(source_view_1->is_selected()); | 150 EXPECT_FALSE(source_view_1->is_selected()); |
| 151 | 151 |
| 152 // Source view 0 is selected with mouse click. | 152 // Source view 0 is selected with mouse click. |
| 153 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), | 153 ui::MouseEvent press( |
| 154 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); | 154 ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), |
| 155 ui::EF_LEFT_MOUSE_BUTTON, 0, |
| 156 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 155 | 157 |
| 156 GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnMousePressed( | 158 GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnMousePressed( |
| 157 press); | 159 press); |
| 158 | 160 |
| 159 EXPECT_TRUE(source_view_0->is_selected()); | 161 EXPECT_TRUE(source_view_0->is_selected()); |
| 160 EXPECT_FALSE(source_view_1->is_selected()); | 162 EXPECT_FALSE(source_view_1->is_selected()); |
| 161 | 163 |
| 162 // Source view 1 is selected and source view 0 is unselected with mouse | 164 // Source view 1 is selected and source view 0 is unselected with mouse |
| 163 // click. | 165 // click. |
| 164 GetPickerDialogView()->GetMediaSourceViewForTesting(1)->OnMousePressed( | 166 GetPickerDialogView()->GetMediaSourceViewForTesting(1)->OnMousePressed( |
| 165 press); | 167 press); |
| 166 | 168 |
| 167 EXPECT_FALSE(source_view_0->is_selected()); | 169 EXPECT_FALSE(source_view_0->is_selected()); |
| 168 EXPECT_TRUE(source_view_1->is_selected()); | 170 EXPECT_TRUE(source_view_1->is_selected()); |
| 169 } | 171 } |
| 170 } | 172 } |
| 171 | 173 |
| 172 TEST_F(DesktopMediaPickerViewsTest, DoneCallbackCalledOnDoubleClick) { | 174 TEST_F(DesktopMediaPickerViewsTest, DoneCallbackCalledOnDoubleClick) { |
| 173 const DesktopMediaID kFakeId(DesktopMediaID::TYPE_WEB_CONTENTS, 222); | 175 const DesktopMediaID kFakeId(DesktopMediaID::TYPE_WEB_CONTENTS, 222); |
| 174 EXPECT_CALL(*this, OnPickerDone(kFakeId)); | 176 EXPECT_CALL(*this, OnPickerDone(kFakeId)); |
| 175 | 177 |
| 176 media_lists_[DesktopMediaID::TYPE_WEB_CONTENTS]->AddSourceByFullMediaID( | 178 media_lists_[DesktopMediaID::TYPE_WEB_CONTENTS]->AddSourceByFullMediaID( |
| 177 kFakeId); | 179 kFakeId); |
| 178 EXPECT_TRUE(ClickSourceTypeButton(DesktopMediaID::TYPE_WEB_CONTENTS)); | 180 EXPECT_TRUE(ClickSourceTypeButton(DesktopMediaID::TYPE_WEB_CONTENTS)); |
| 179 GetPickerDialogView()->GetCheckboxForTesting()->SetChecked(false); | 181 GetPickerDialogView()->GetCheckboxForTesting()->SetChecked(false); |
| 180 | 182 |
| 181 ui::MouseEvent double_click(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), | 183 ui::MouseEvent double_click( |
| 182 ui::EventTimeForNow(), | 184 ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), |
| 183 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_IS_DOUBLE_CLICK, | 185 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_IS_DOUBLE_CLICK, |
| 184 ui::EF_LEFT_MOUSE_BUTTON); | 186 ui::EF_LEFT_MOUSE_BUTTON, |
| 187 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 185 | 188 |
| 186 GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnMousePressed( | 189 GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnMousePressed( |
| 187 double_click); | 190 double_click); |
| 188 base::RunLoop().RunUntilIdle(); | 191 base::RunLoop().RunUntilIdle(); |
| 189 } | 192 } |
| 190 | 193 |
| 191 TEST_F(DesktopMediaPickerViewsTest, DoneCallbackCalledOnDoubleTap) { | 194 TEST_F(DesktopMediaPickerViewsTest, DoneCallbackCalledOnDoubleTap) { |
| 192 const DesktopMediaID kFakeId(DesktopMediaID::TYPE_SCREEN, 222); | 195 const DesktopMediaID kFakeId(DesktopMediaID::TYPE_SCREEN, 222); |
| 193 EXPECT_CALL(*this, OnPickerDone(kFakeId)); | 196 EXPECT_CALL(*this, OnPickerDone(kFakeId)); |
| 194 | 197 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 317 |
| 315 EXPECT_TRUE(ClickSourceTypeButton(DesktopMediaID::TYPE_WEB_CONTENTS)); | 318 EXPECT_TRUE(ClickSourceTypeButton(DesktopMediaID::TYPE_WEB_CONTENTS)); |
| 316 GetPickerDialogView()->GetCheckboxForTesting()->SetChecked(true); | 319 GetPickerDialogView()->GetCheckboxForTesting()->SetChecked(true); |
| 317 GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnFocus(); | 320 GetPickerDialogView()->GetMediaSourceViewForTesting(0)->OnFocus(); |
| 318 | 321 |
| 319 GetPickerDialogView()->GetDialogClientView()->AcceptWindow(); | 322 GetPickerDialogView()->GetDialogClientView()->AcceptWindow(); |
| 320 base::RunLoop().RunUntilIdle(); | 323 base::RunLoop().RunUntilIdle(); |
| 321 } | 324 } |
| 322 | 325 |
| 323 } // namespace views | 326 } // namespace views |
| OLD | NEW |