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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/accelerators/accelerator_controller.h" | 10 #include "ash/accelerators/accelerator_controller.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 ~ModalWidgetDelegate() override {} | 49 ~ModalWidgetDelegate() override {} |
50 | 50 |
51 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_SYSTEM; } | 51 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_SYSTEM; } |
52 | 52 |
53 private: | 53 private: |
54 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); | 54 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); |
55 }; | 55 }; |
56 | 56 |
57 } // namespace | 57 } // namespace |
58 | 58 |
59 typedef AshTestBase SystemTrayTest; | 59 class SystemTrayTest : public AshTestBase { |
60 public: | |
61 SystemTrayTest() {} | |
62 ~SystemTrayTest() override {} | |
63 | |
64 void SetUp() override { | |
65 AshTestBase::SetUp(); | |
66 shelf_ = GetPrimaryShelf(); | |
67 system_tray_ = GetPrimarySystemTray(); | |
68 } | |
69 | |
70 void set_in_maximize_mode(bool in_maximize_mode) { | |
71 system_tray_->in_maximize_mode_ = in_maximize_mode; | |
72 } | |
73 | |
74 void SendGestureEvent(gfx::Point& start, float delta) { | |
75 base::TimeTicks timestamp = base::TimeTicks::Now(); | |
76 ui::GestureEventDetails begin_details(ui::ET_GESTURE_SCROLL_BEGIN); | |
77 ui::GestureEvent begin_event = ui::GestureEvent( | |
78 start.x(), start.y(), ui::EF_NONE, timestamp, begin_details); | |
79 system_tray_->OnGestureEvent(&begin_event); | |
80 | |
81 ui::GestureEventDetails update_details(ui::ET_GESTURE_SCROLL_UPDATE, 0, | |
82 delta); | |
83 timestamp += base::TimeDelta::FromMilliseconds(100); | |
84 ui::GestureEvent update_event = ui::GestureEvent( | |
85 start.x(), start.y(), ui::EF_NONE, timestamp, update_details); | |
86 system_tray_->OnGestureEvent(&update_event); | |
87 | |
88 ui::GestureEventDetails end_details(ui::ET_GESTURE_SCROLL_END); | |
89 ui::GestureEvent end_event = ui::GestureEvent( | |
90 start.x(), start.y() + delta, ui::EF_NONE, timestamp, end_details); | |
91 system_tray_->OnGestureEvent(&end_event); | |
92 } | |
93 | |
94 float height() { | |
xiyuan
2017/06/16 17:33:43
nit: height -> GetSystemBubbleHeight
minch1
2017/06/16 22:11:51
Done.
| |
95 gfx::Rect bounds = gfx::Rect(); | |
96 if (system_tray_->HasSystemBubble()) { | |
97 bounds = system_tray_->GetSystemBubble() | |
98 ->bubble_view() | |
99 ->GetWidget() | |
100 ->GetWindowBoundsInScreen(); | |
101 } | |
102 return bounds.height(); | |
103 } | |
104 | |
105 Shelf* shelf() { return shelf_; } | |
106 SystemTray* system_tray() { return system_tray_; } | |
107 | |
108 private: | |
109 Shelf* shelf_ = nullptr; | |
110 SystemTray* system_tray_ = nullptr; | |
111 | |
112 DISALLOW_COPY_AND_ASSIGN(SystemTrayTest); | |
113 }; | |
114 | |
115 TEST_F(SystemTrayTest, SwipingOnSystemTray) { | |
116 gfx::Point start = system_tray()->GetBoundsInScreen().CenterPoint(); | |
117 shelf()->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | |
118 system_tray()->ShowDefaultView(BUBBLE_CREATE_NEW); | |
119 float delta = -height(); | |
120 system_tray()->CloseSystemBubble(); | |
121 | |
122 // Swiping up on the system tray has no effect if it is not in maximize mode. | |
123 set_in_maximize_mode(false); | |
124 ASSERT_FALSE(system_tray()->HasSystemBubble()); | |
125 SendGestureEvent(start, delta); | |
126 ASSERT_FALSE(system_tray()->HasSystemBubble()); | |
127 | |
128 // Swiping up on the system tray should show the system tray bubble if it is | |
129 // in masimize mode. | |
xiyuan
2017/06/16 17:33:43
nit: masimize -> maximize
minch1
2017/06/16 22:11:51
Done.
| |
130 set_in_maximize_mode(true); | |
131 SendGestureEvent(start, delta); | |
132 ASSERT_TRUE(system_tray()->HasSystemBubble()); | |
xiyuan
2017/06/16 17:33:43
nit: ASSERT_TRUE -> EXPECT_TRUE
Use ASSERT_xxx wh
minch1
2017/06/16 22:11:51
Done.
| |
133 | |
xiyuan
2017/06/16 17:33:43
nit: move this empty line after CloseSystemBubble(
minch1
2017/06/16 22:11:51
Done.
| |
134 system_tray()->CloseSystemBubble(); | |
135 // Swiping up less than one third of the bubble's height should not show the | |
136 // bubble. | |
137 delta /= 4; | |
138 SendGestureEvent(start, delta); | |
139 ASSERT_FALSE(system_tray()->HasSystemBubble()); | |
140 | |
141 // Swiping up on system tray should not show the system tray bubble if the | |
142 // shelf is left alignment. | |
143 delta = height(); | |
144 shelf()->SetAlignment(SHELF_ALIGNMENT_LEFT); | |
145 SendGestureEvent(start, delta); | |
146 ASSERT_FALSE(system_tray()->HasSystemBubble()); | |
147 | |
148 // Swiping up on system tray should not show the system tray bubble if the | |
149 // shelf is right alignment. | |
150 shelf()->SetAlignment(SHELF_ALIGNMENT_RIGHT); | |
151 SendGestureEvent(start, delta); | |
152 ASSERT_FALSE(system_tray()->HasSystemBubble()); | |
153 | |
154 // Swiping down on the shelf should not show the system tray bubble. | |
155 shelf()->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | |
156 delta = -delta; | |
157 SendGestureEvent(start, delta); | |
158 ASSERT_FALSE(system_tray()->HasSystemBubble()); | |
159 } | |
60 | 160 |
61 // Verifies only the visible default views are recorded in the | 161 // Verifies only the visible default views are recorded in the |
62 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram. | 162 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram. |
63 TEST_F(SystemTrayTest, OnlyVisibleItemsRecorded) { | 163 TEST_F(SystemTrayTest, OnlyVisibleItemsRecorded) { |
64 SystemTray* tray = GetPrimarySystemTray(); | 164 SystemTray* tray = GetPrimarySystemTray(); |
65 ASSERT_TRUE(tray->GetWidget()); | 165 ASSERT_TRUE(tray->GetWidget()); |
66 | 166 |
67 TestSystemTrayItem* test_item = new TestSystemTrayItem(); | 167 TestSystemTrayItem* test_item = new TestSystemTrayItem(); |
68 tray->AddTrayItem(base::WrapUnique(test_item)); | 168 tray->AddTrayItem(base::WrapUnique(test_item)); |
69 | 169 |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
586 | 686 |
587 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); | 687 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); |
588 } | 688 } |
589 | 689 |
590 TEST_F(SystemTrayTest, SeparatorThickness) { | 690 TEST_F(SystemTrayTest, SeparatorThickness) { |
591 EXPECT_EQ(kSeparatorWidth, views::Separator::kThickness); | 691 EXPECT_EQ(kSeparatorWidth, views::Separator::kThickness); |
592 } | 692 } |
593 | 693 |
594 } // namespace test | 694 } // namespace test |
595 } // namespace ash | 695 } // namespace ash |
OLD | NEW |