| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/system/tray/tray_details_view.h" | 5 #include "ash/system/tray/tray_details_view.h" |
| 6 | 6 |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/shelf/shelf_widget.h" | 8 #include "ash/shelf/shelf_widget.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/system/status_area_widget.h" | 10 #include "ash/system/status_area_widget.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 } | 194 } |
| 195 | 195 |
| 196 // Tests that HoverHighlightView enters hover state in response to touch. | 196 // Tests that HoverHighlightView enters hover state in response to touch. |
| 197 TEST_F(TrayDetailsViewTest, HoverHighlightViewTouchFeedback) { | 197 TEST_F(TrayDetailsViewTest, HoverHighlightViewTouchFeedback) { |
| 198 HoverHighlightView* view = CreateAndShowHoverHighlightView(); | 198 HoverHighlightView* view = CreateAndShowHoverHighlightView(); |
| 199 EXPECT_FALSE(view->hover()); | 199 EXPECT_FALSE(view->hover()); |
| 200 | 200 |
| 201 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 201 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 202 generator.set_current_location(view->GetBoundsInScreen().CenterPoint()); | 202 generator.set_current_location(view->GetBoundsInScreen().CenterPoint()); |
| 203 generator.PressTouch(); | 203 generator.PressTouch(); |
| 204 RunAllPendingInMessageLoop(); | |
| 205 EXPECT_TRUE(view->hover()); | 204 EXPECT_TRUE(view->hover()); |
| 206 | 205 |
| 207 generator.ReleaseTouch(); | 206 generator.ReleaseTouch(); |
| 208 RunAllPendingInMessageLoop(); | |
| 209 EXPECT_FALSE(view->hover()); | 207 EXPECT_FALSE(view->hover()); |
| 210 } | 208 } |
| 211 | 209 |
| 212 // Tests that touch events leaving HoverHighlightView cancel the hover state. | 210 // Tests that touch events leaving HoverHighlightView cancel the hover state. |
| 213 TEST_F(TrayDetailsViewTest, HoverHighlightViewTouchFeedbackCancellation) { | 211 TEST_F(TrayDetailsViewTest, HoverHighlightViewTouchFeedbackCancellation) { |
| 214 HoverHighlightView* view = CreateAndShowHoverHighlightView(); | 212 HoverHighlightView* view = CreateAndShowHoverHighlightView(); |
| 215 EXPECT_FALSE(view->hover()); | 213 EXPECT_FALSE(view->hover()); |
| 216 | 214 |
| 217 gfx::Rect view_bounds = view->GetBoundsInScreen(); | 215 gfx::Rect view_bounds = view->GetBoundsInScreen(); |
| 218 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 216 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 219 generator.set_current_location(view_bounds.CenterPoint()); | 217 generator.set_current_location(view_bounds.CenterPoint()); |
| 220 generator.PressTouch(); | 218 generator.PressTouch(); |
| 221 RunAllPendingInMessageLoop(); | |
| 222 EXPECT_TRUE(view->hover()); | 219 EXPECT_TRUE(view->hover()); |
| 223 | 220 |
| 224 gfx::Point move_point(view_bounds.x(), view_bounds.CenterPoint().y()); | 221 gfx::Point move_point(view_bounds.x(), view_bounds.CenterPoint().y()); |
| 225 generator.MoveTouch(move_point); | 222 generator.MoveTouch(move_point); |
| 226 RunAllPendingInMessageLoop(); | |
| 227 EXPECT_FALSE(view->hover()); | 223 EXPECT_FALSE(view->hover()); |
| 228 | 224 |
| 229 generator.set_current_location(move_point); | 225 generator.set_current_location(move_point); |
| 230 generator.ReleaseTouch(); | 226 generator.ReleaseTouch(); |
| 231 RunAllPendingInMessageLoop(); | |
| 232 EXPECT_FALSE(view->hover()); | 227 EXPECT_FALSE(view->hover()); |
| 233 } | 228 } |
| 234 | 229 |
| 235 // Tests that TrayPopupHeaderButton renders a background in response to touch. | 230 // Tests that TrayPopupHeaderButton renders a background in response to touch. |
| 236 TEST_F(TrayDetailsViewTest, TrayPopupHeaderButtonTouchFeedback) { | 231 TEST_F(TrayDetailsViewTest, TrayPopupHeaderButtonTouchFeedback) { |
| 237 TrayPopupHeaderButton* button = CreateAndShowTrayPopupHeaderButton(); | 232 TrayPopupHeaderButton* button = CreateAndShowTrayPopupHeaderButton(); |
| 238 EXPECT_FALSE(button->background()); | 233 EXPECT_FALSE(button->background()); |
| 239 | 234 |
| 240 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 235 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 241 generator.set_current_location(button->GetBoundsInScreen().CenterPoint()); | 236 generator.set_current_location(button->GetBoundsInScreen().CenterPoint()); |
| 242 generator.PressTouch(); | 237 generator.PressTouch(); |
| 243 RunAllPendingInMessageLoop(); | |
| 244 EXPECT_TRUE(button->background()); | 238 EXPECT_TRUE(button->background()); |
| 245 | 239 |
| 246 generator.ReleaseTouch(); | 240 generator.ReleaseTouch(); |
| 247 RunAllPendingInMessageLoop(); | |
| 248 EXPECT_FALSE(button->background()); | 241 EXPECT_FALSE(button->background()); |
| 249 } | 242 } |
| 250 | 243 |
| 251 // Tests that touch events leaving TrayPopupHeaderButton cancel the touch | 244 // Tests that touch events leaving TrayPopupHeaderButton cancel the touch |
| 252 // feedback background. | 245 // feedback background. |
| 253 TEST_F(TrayDetailsViewTest, TrayPopupHeaderButtonTouchFeedbackCancellation) { | 246 TEST_F(TrayDetailsViewTest, TrayPopupHeaderButtonTouchFeedbackCancellation) { |
| 254 TrayPopupHeaderButton* button = CreateAndShowTrayPopupHeaderButton(); | 247 TrayPopupHeaderButton* button = CreateAndShowTrayPopupHeaderButton(); |
| 255 EXPECT_FALSE(button->background()); | 248 EXPECT_FALSE(button->background()); |
| 256 | 249 |
| 257 gfx::Rect view_bounds = button->GetBoundsInScreen(); | 250 gfx::Rect view_bounds = button->GetBoundsInScreen(); |
| 258 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 251 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 259 generator.set_current_location(view_bounds.CenterPoint()); | 252 generator.set_current_location(view_bounds.CenterPoint()); |
| 260 generator.PressTouch(); | 253 generator.PressTouch(); |
| 261 RunAllPendingInMessageLoop(); | |
| 262 EXPECT_TRUE(button->background()); | 254 EXPECT_TRUE(button->background()); |
| 263 | 255 |
| 264 gfx::Point move_point(view_bounds.x(), view_bounds.CenterPoint().y()); | 256 gfx::Point move_point(view_bounds.x(), view_bounds.CenterPoint().y()); |
| 265 generator.MoveTouch(move_point); | 257 generator.MoveTouch(move_point); |
| 266 RunAllPendingInMessageLoop(); | |
| 267 EXPECT_FALSE(button->background()); | 258 EXPECT_FALSE(button->background()); |
| 268 | 259 |
| 269 generator.set_current_location(move_point); | 260 generator.set_current_location(move_point); |
| 270 generator.ReleaseTouch(); | 261 generator.ReleaseTouch(); |
| 271 RunAllPendingInMessageLoop(); | |
| 272 EXPECT_FALSE(button->background()); | 262 EXPECT_FALSE(button->background()); |
| 273 } | 263 } |
| 274 | 264 |
| 275 // Tests that a mouse entering TrayPopupHeaderButton renders a background as | 265 // Tests that a mouse entering TrayPopupHeaderButton renders a background as |
| 276 // visual feedback. | 266 // visual feedback. |
| 277 TEST_F(TrayDetailsViewTest, TrayPopupHeaderButtonMouseHoverFeedback) { | 267 TEST_F(TrayDetailsViewTest, TrayPopupHeaderButtonMouseHoverFeedback) { |
| 278 TrayPopupHeaderButton* button = CreateAndShowTrayPopupHeaderButton(); | 268 TrayPopupHeaderButton* button = CreateAndShowTrayPopupHeaderButton(); |
| 279 EXPECT_FALSE(button->background()); | 269 EXPECT_FALSE(button->background()); |
| 280 | 270 |
| 281 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 271 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 282 gfx::Rect bounds = button->GetBoundsInScreen(); | 272 gfx::Rect bounds = button->GetBoundsInScreen(); |
| 283 gfx::Point initial_point(bounds.x() - 1, bounds.y()); | 273 gfx::Point initial_point(bounds.x() - 1, bounds.y()); |
| 284 generator.set_current_location(initial_point); | 274 generator.set_current_location(initial_point); |
| 285 generator.MoveMouseBy(1, 0); | 275 generator.MoveMouseBy(1, 0); |
| 286 RunAllPendingInMessageLoop(); | 276 RunAllPendingInMessageLoop(); |
| 287 EXPECT_TRUE(button->background()); | 277 EXPECT_TRUE(button->background()); |
| 288 } | 278 } |
| 289 | 279 |
| 290 } // namespace test | 280 } // namespace test |
| 291 } // namespace ash | 281 } // namespace ash |
| OLD | NEW |