| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/system_tray.h" | 5 #include "ash/system/tray/system_tray.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/accessibility_delegate.h" | 9 #include "ash/accessibility_delegate.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| 11 #include "ash/shelf/shelf_layout_manager.h" | 11 #include "ash/shelf/shelf_layout_manager.h" |
| 12 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ash/system/status_area_widget.h" | 14 #include "ash/system/status_area_widget.h" |
| 15 #include "ash/system/tray/system_tray_bubble.h" |
| 15 #include "ash/system/tray/system_tray_item.h" | 16 #include "ash/system/tray/system_tray_item.h" |
| 16 #include "ash/system/tray/tray_constants.h" | 17 #include "ash/system/tray/tray_constants.h" |
| 18 #include "ash/system/tray/tray_popup_item_container.h" |
| 17 #include "ash/test/ash_test_base.h" | 19 #include "ash/test/ash_test_base.h" |
| 18 #include "ash/wm/window_util.h" | 20 #include "ash/wm/window_util.h" |
| 21 #include "base/command_line.h" |
| 19 #include "base/run_loop.h" | 22 #include "base/run_loop.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 21 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
| 25 #include "ui/base/ui_base_switches.h" |
| 22 #include "ui/base/ui_base_types.h" | 26 #include "ui/base/ui_base_types.h" |
| 23 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 27 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 24 #include "ui/events/test/event_generator.h" | 28 #include "ui/events/test/event_generator.h" |
| 29 #include "ui/gfx/geometry/point.h" |
| 25 #include "ui/gfx/geometry/rect.h" | 30 #include "ui/gfx/geometry/rect.h" |
| 26 #include "ui/views/controls/label.h" | 31 #include "ui/views/controls/label.h" |
| 27 #include "ui/views/layout/fill_layout.h" | 32 #include "ui/views/layout/fill_layout.h" |
| 28 #include "ui/views/view.h" | 33 #include "ui/views/view.h" |
| 29 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
| 30 #include "ui/views/widget/widget_delegate.h" | 35 #include "ui/views/widget/widget_delegate.h" |
| 31 | 36 |
| 32 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
| 33 #include "base/win/windows_version.h" | 38 #include "base/win/windows_version.h" |
| 34 #endif | 39 #endif |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 virtual ui::ModalType GetModalType() const override { | 155 virtual ui::ModalType GetModalType() const override { |
| 151 return ui::MODAL_TYPE_SYSTEM; | 156 return ui::MODAL_TYPE_SYSTEM; |
| 152 } | 157 } |
| 153 | 158 |
| 154 private: | 159 private: |
| 155 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); | 160 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); |
| 156 }; | 161 }; |
| 157 | 162 |
| 158 } // namespace | 163 } // namespace |
| 159 | 164 |
| 160 typedef AshTestBase SystemTrayTest; | 165 class SystemTrayTest : public AshTestBase { |
| 166 public: |
| 167 SystemTrayTest() {} |
| 168 virtual ~SystemTrayTest() {} |
| 169 |
| 170 virtual void SetUp() OVERRIDE { |
| 171 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 172 switches::kEnableTouchFeedback); |
| 173 test::AshTestBase::SetUp(); |
| 174 } |
| 175 |
| 176 private: |
| 177 DISALLOW_COPY_AND_ASSIGN(SystemTrayTest); |
| 178 }; |
| 161 | 179 |
| 162 TEST_F(SystemTrayTest, SystemTrayDefaultView) { | 180 TEST_F(SystemTrayTest, SystemTrayDefaultView) { |
| 163 SystemTray* tray = GetSystemTray(); | 181 SystemTray* tray = GetSystemTray(); |
| 164 ASSERT_TRUE(tray->GetWidget()); | 182 ASSERT_TRUE(tray->GetWidget()); |
| 165 | 183 |
| 166 tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 184 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 167 | 185 |
| 168 // Ensure that closing the bubble destroys it. | 186 // Ensure that closing the bubble destroys it. |
| 169 ASSERT_TRUE(tray->CloseSystemBubble()); | 187 ASSERT_TRUE(tray->CloseSystemBubble()); |
| 170 RunAllPendingInMessageLoop(); | 188 RunAllPendingInMessageLoop(); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 EXPECT_TRUE(tray->visible()); | 516 EXPECT_TRUE(tray->visible()); |
| 499 EXPECT_EQ(0.0f, tray->layer()->GetTargetOpacity()); | 517 EXPECT_EQ(0.0f, tray->layer()->GetTargetOpacity()); |
| 500 | 518 |
| 501 tray->SetVisible(true); | 519 tray->SetVisible(true); |
| 502 animation_duration.reset(); | 520 animation_duration.reset(); |
| 503 tray->layer()->GetAnimator()->StopAnimating(); | 521 tray->layer()->GetAnimator()->StopAnimating(); |
| 504 EXPECT_TRUE(tray->visible()); | 522 EXPECT_TRUE(tray->visible()); |
| 505 EXPECT_EQ(1.0f, tray->layer()->GetTargetOpacity()); | 523 EXPECT_EQ(1.0f, tray->layer()->GetTargetOpacity()); |
| 506 } | 524 } |
| 507 | 525 |
| 526 #if defined(OS_CHROMEOS) |
| 527 // Tests that touch on an item in the system bubble triggers it to become |
| 528 // active. |
| 529 TEST_F(SystemTrayTest, TrayPopupItemContainerTouchFeedback) { |
| 530 SystemTray* tray = GetSystemTray(); |
| 531 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 532 |
| 533 TrayPopupItemContainer* view = |
| 534 static_cast<TrayPopupItemContainer*>(tray->GetSystemBubble()-> |
| 535 bubble_view()->child_at(0)); |
| 536 EXPECT_FALSE(view->active()); |
| 537 |
| 538 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 539 generator.set_current_location(view->GetBoundsInScreen().CenterPoint()); |
| 540 generator.PressTouch(); |
| 541 RunAllPendingInMessageLoop(); |
| 542 EXPECT_TRUE(view->active()); |
| 543 |
| 544 generator.ReleaseTouch(); |
| 545 RunAllPendingInMessageLoop(); |
| 546 EXPECT_FALSE(view->active()); |
| 547 } |
| 548 |
| 549 // Tests that touch events on an item in the system bubble cause it to stop |
| 550 // being active. |
| 551 TEST_F(SystemTrayTest, TrayPopupItemContainerTouchFeedbackCancellation) { |
| 552 SystemTray* tray = GetSystemTray(); |
| 553 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 554 |
| 555 TrayPopupItemContainer* view = |
| 556 static_cast<TrayPopupItemContainer*>(tray->GetSystemBubble()-> |
| 557 bubble_view()->child_at(0)); |
| 558 EXPECT_FALSE(view->active()); |
| 559 |
| 560 gfx::Rect view_bounds = view->GetBoundsInScreen(); |
| 561 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 562 generator.set_current_location(view_bounds.CenterPoint()); |
| 563 generator.PressTouch(); |
| 564 RunAllPendingInMessageLoop(); |
| 565 EXPECT_TRUE(view->active()); |
| 566 |
| 567 gfx::Point move_point(view_bounds.x(), view_bounds.CenterPoint().y()); |
| 568 generator.MoveTouch(move_point); |
| 569 RunAllPendingInMessageLoop(); |
| 570 EXPECT_FALSE(view->active()); |
| 571 |
| 572 generator.set_current_location(move_point); |
| 573 generator.ReleaseTouch(); |
| 574 RunAllPendingInMessageLoop(); |
| 575 EXPECT_FALSE(view->active()); |
| 576 } |
| 577 #endif // OS_CHROMEOS |
| 578 |
| 508 } // namespace test | 579 } // namespace test |
| 509 } // namespace ash | 580 } // namespace ash |
| OLD | NEW |