Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: ash/system/tray/system_tray_unittest.cc

Issue 556383002: Status Panel Touch Feedback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ash_switches.h"
10 #include "ash/root_window_controller.h" 11 #include "ash/root_window_controller.h"
11 #include "ash/shelf/shelf_layout_manager.h" 12 #include "ash/shelf/shelf_layout_manager.h"
12 #include "ash/shelf/shelf_widget.h" 13 #include "ash/shelf/shelf_widget.h"
13 #include "ash/shell.h" 14 #include "ash/shell.h"
14 #include "ash/system/status_area_widget.h" 15 #include "ash/system/status_area_widget.h"
16 #include "ash/system/tray/system_tray_bubble.h"
15 #include "ash/system/tray/system_tray_item.h" 17 #include "ash/system/tray/system_tray_item.h"
16 #include "ash/system/tray/tray_constants.h" 18 #include "ash/system/tray/tray_constants.h"
19 #include "ash/system/tray/tray_popup_item_container.h"
17 #include "ash/test/ash_test_base.h" 20 #include "ash/test/ash_test_base.h"
18 #include "ash/wm/window_util.h" 21 #include "ash/wm/window_util.h"
22 #include "base/command_line.h"
19 #include "base/run_loop.h" 23 #include "base/run_loop.h"
20 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
21 #include "ui/aura/window.h" 25 #include "ui/aura/window.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
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::kAshEnableTouchViewTouchFeedback);
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
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 // Tests that touch on an item in the system bubble triggers it to become
527 // active.
528 TEST_F(SystemTrayTest, TrayPopupItemContainerTouchFeedback) {
529 SystemTray* tray = GetSystemTray();
530 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
531
532 TrayPopupItemContainer* view =
533 static_cast<TrayPopupItemContainer*>(tray->GetSystemBubble()->
534 bubble_view()->child_at(0));
535 EXPECT_FALSE(view->active());
536
537 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
538 generator.set_current_location(view->GetBoundsInScreen().CenterPoint());
539 generator.PressTouch();
540 RunAllPendingInMessageLoop();
541 EXPECT_TRUE(view->active());
542
543 generator.ReleaseTouch();
544 RunAllPendingInMessageLoop();
545 EXPECT_FALSE(view->active());
546 }
547
548 // Tests that touch events on an item in the system bubble cause it to stop
549 // being active.
550 TEST_F(SystemTrayTest, TrayPopupItemContainerTouchFeedbackCancellation) {
551 SystemTray* tray = GetSystemTray();
552 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
553
554 TrayPopupItemContainer* view =
555 static_cast<TrayPopupItemContainer*>(tray->GetSystemBubble()->
556 bubble_view()->child_at(0));
557 EXPECT_FALSE(view->active());
558
559 gfx::Rect view_bounds = view->GetBoundsInScreen();
560 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
561 generator.set_current_location(view_bounds.CenterPoint());
562 generator.PressTouch();
563 RunAllPendingInMessageLoop();
564 EXPECT_TRUE(view->active());
565
566 gfx::Point move_point(view_bounds.x(), view_bounds.CenterPoint().y());
jonross 2014/09/11 15:53:23 Moving directly out of bounds causes the view to n
flackr 2014/09/11 20:49:37 Sounds like a bug. Can you file and reference?
jonross 2014/09/12 18:57:48 crbug.com/413844 filed
567 generator.MoveTouch(move_point);
568 RunAllPendingInMessageLoop();
569 EXPECT_FALSE(view->active());
570
571 generator.set_current_location(move_point);
572 generator.ReleaseTouch();
573 RunAllPendingInMessageLoop();
574 EXPECT_FALSE(view->active());
575 }
576
508 } // namespace test 577 } // namespace test
509 } // namespace ash 578 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698