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

Unified 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 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 74c7c0217a73d84f07e625db05d1bb7bc85e3b2e..875f0eae1790dc55b995026363eb363e2b3bebe6 100644
--- a/ash/system/tray/system_tray_unittest.cc
+++ b/ash/system/tray/system_tray_unittest.cc
@@ -7,21 +7,26 @@
#include <vector>
#include "ash/accessibility_delegate.h"
+#include "ash/ash_switches.h"
#include "ash/root_window_controller.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#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/tray_constants.h"
+#include "ash/system/tray/tray_popup_item_container.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/window_util.h"
+#include "base/command_line.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/aura/window.h"
#include "ui/base/ui_base_types.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/events/test/event_generator.h"
+#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/fill_layout.h"
@@ -157,7 +162,20 @@ class ModalWidgetDelegate : public views::WidgetDelegateView {
} // namespace
-typedef AshTestBase SystemTrayTest;
+class SystemTrayTest : public AshTestBase {
+ public:
+ SystemTrayTest() {}
+ virtual ~SystemTrayTest() {}
+
+ virtual void SetUp() OVERRIDE {
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kAshEnableTouchViewTouchFeedback);
+ test::AshTestBase::SetUp();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SystemTrayTest);
+};
TEST_F(SystemTrayTest, SystemTrayDefaultView) {
SystemTray* tray = GetSystemTray();
@@ -505,5 +523,56 @@ TEST_F(SystemTrayTest, SetVisibleDuringHideAnimation) {
EXPECT_EQ(1.0f, tray->layer()->GetTargetOpacity());
}
+// Tests that touch on an item in the system bubble triggers it to become
+// active.
+TEST_F(SystemTrayTest, TrayPopupItemContainerTouchFeedback) {
+ SystemTray* tray = GetSystemTray();
+ tray->ShowDefaultView(BUBBLE_CREATE_NEW);
+
+ TrayPopupItemContainer* view =
+ static_cast<TrayPopupItemContainer*>(tray->GetSystemBubble()->
+ bubble_view()->child_at(0));
+ EXPECT_FALSE(view->active());
+
+ ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
+ generator.set_current_location(view->GetBoundsInScreen().CenterPoint());
+ generator.PressTouch();
+ RunAllPendingInMessageLoop();
+ EXPECT_TRUE(view->active());
+
+ generator.ReleaseTouch();
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(view->active());
+}
+
+// Tests that touch events on an item in the system bubble cause it to stop
+// being active.
+TEST_F(SystemTrayTest, TrayPopupItemContainerTouchFeedbackCancellation) {
+ SystemTray* tray = GetSystemTray();
+ tray->ShowDefaultView(BUBBLE_CREATE_NEW);
+
+ TrayPopupItemContainer* view =
+ static_cast<TrayPopupItemContainer*>(tray->GetSystemBubble()->
+ bubble_view()->child_at(0));
+ EXPECT_FALSE(view->active());
+
+ gfx::Rect view_bounds = view->GetBoundsInScreen();
+ ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
+ generator.set_current_location(view_bounds.CenterPoint());
+ generator.PressTouch();
+ RunAllPendingInMessageLoop();
+ EXPECT_TRUE(view->active());
+
+ 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
+ generator.MoveTouch(move_point);
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(view->active());
+
+ generator.set_current_location(move_point);
+ generator.ReleaseTouch();
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(view->active());
+}
+
} // namespace test
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698