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

Unified Diff: ash/system/tray/system_tray_unittest.cc

Issue 2930123002: Tablet WM : Swiping on system tray bubble. (Closed)
Patch Set: Addressed xiyuan's comments. Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: ash/system/tray/system_tray_unittest.cc
diff --git a/ash/system/tray/system_tray_unittest.cc b/ash/system/tray/system_tray_unittest.cc
index c8dc570c4f0103ed481221f980abfc7c284330cf..d670e2057988f9eaf75f617658e9e5687284c45b 100644
--- a/ash/system/tray/system_tray_unittest.cc
+++ b/ash/system/tray/system_tray_unittest.cc
@@ -16,6 +16,7 @@
#include "ash/system/status_area_widget.h"
#include "ash/system/tray/system_tray_bubble.h"
#include "ash/system/tray/system_tray_item.h"
+#include "ash/system/tray/system_tray_test_api.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/web_notification/web_notification_tray.h"
#include "ash/test/ash_test_base.h"
@@ -56,7 +57,95 @@ class ModalWidgetDelegate : public views::WidgetDelegateView {
} // namespace
-typedef AshTestBase SystemTrayTest;
+class SystemTrayTest : public AshTestBase {
+ public:
+ SystemTrayTest() {}
+ ~SystemTrayTest() override {}
+
+ void SendGestureEvent(gfx::Point& start, float delta) {
+ SystemTray* system_tray = GetPrimarySystemTray();
+ base::TimeTicks timestamp = base::TimeTicks::Now();
+ ui::GestureEventDetails begin_details(ui::ET_GESTURE_SCROLL_BEGIN);
+ ui::GestureEvent begin_event = ui::GestureEvent(
+ start.x(), start.y(), ui::EF_NONE, timestamp, begin_details);
+ system_tray->OnGestureEvent(&begin_event);
+
+ ui::GestureEventDetails update_details(ui::ET_GESTURE_SCROLL_UPDATE, 0,
+ delta);
+ timestamp += base::TimeDelta::FromMilliseconds(100);
+ ui::GestureEvent update_event = ui::GestureEvent(
+ start.x(), start.y(), ui::EF_NONE, timestamp, update_details);
+ system_tray->OnGestureEvent(&update_event);
+
+ ui::GestureEventDetails end_details(ui::ET_GESTURE_SCROLL_END);
+ ui::GestureEvent end_event = ui::GestureEvent(
+ start.x(), start.y() + delta, ui::EF_NONE, timestamp, end_details);
+ system_tray->OnGestureEvent(&end_event);
+ }
+
+ float GetSystemBubbleHeight() {
+ SystemTray* system_tray = GetPrimarySystemTray();
+ gfx::Rect bounds = gfx::Rect();
+ if (system_tray->HasSystemBubble()) {
+ bounds = system_tray->GetSystemBubble()
+ ->bubble_view()
+ ->GetWidget()
+ ->GetWindowBoundsInScreen();
+ }
+ return bounds.height();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SystemTrayTest);
+};
+
+TEST_F(SystemTrayTest, SwipingOnSystemTray) {
tdanderson 2017/06/19 16:19:38 Can you also add a test to verify the correct beha
minch1 2017/06/20 16:45:35 Done.
+ Shelf* shelf = GetPrimaryShelf();
+ SystemTray* system_tray = GetPrimarySystemTray();
+ gfx::Point start = system_tray->GetBoundsInScreen().CenterPoint();
+ shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
+ system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
+ float delta = -GetSystemBubbleHeight();
+ system_tray->CloseSystemBubble();
+
+ // Swiping up on the system tray has no effect if it is not in maximize mode.
+ SystemTrayTestApi(system_tray).set_in_maximize_mode(false);
+ ASSERT_FALSE(system_tray->HasSystemBubble());
+ SendGestureEvent(start, delta);
+ EXPECT_FALSE(system_tray->HasSystemBubble());
+
+ // Swiping up on the system tray should show the system tray bubble if it is
+ // in maximize mode.
+ SystemTrayTestApi(system_tray).set_in_maximize_mode(true);
+ SendGestureEvent(start, delta);
tdanderson 2017/06/19 16:19:39 Consider adding a test case where |delta| is past
minch1 2017/06/20 16:45:35 Done.
+ EXPECT_TRUE(system_tray->HasSystemBubble());
+ system_tray->CloseSystemBubble();
+
+ // Swiping up less than one third of the bubble's height should not show the
+ // bubble.
+ delta /= 4;
+ SendGestureEvent(start, delta);
+ EXPECT_FALSE(system_tray->HasSystemBubble());
+
+ // Swiping up on system tray should not show the system tray bubble if the
+ // shelf is left alignment.
+ delta = GetSystemBubbleHeight();
+ shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
+ SendGestureEvent(start, delta);
+ EXPECT_FALSE(system_tray->HasSystemBubble());
+
+ // Swiping up on system tray should not show the system tray bubble if the
+ // shelf is right alignment.
+ shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
+ SendGestureEvent(start, delta);
+ EXPECT_FALSE(system_tray->HasSystemBubble());
+
+ // Swiping down on the shelf should not show the system tray bubble.
+ shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
+ delta = -delta;
+ SendGestureEvent(start, delta);
+ EXPECT_FALSE(system_tray->HasSystemBubble());
+}
// Verifies only the visible default views are recorded in the
// "Ash.SystemMenu.DefaultView.VisibleItems" histogram.
« ash/system/tray/system_tray_bubble.cc ('K') | « ash/system/tray/system_tray_test_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698