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

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

Issue 556383002: Status Panel Touch Feedback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restrict test to ChromeOS Created 6 years, 2 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
« no previous file with comments | « ash/system/tray/system_tray_unittest.cc ('k') | ash/system/tray/tray_popup_item_container.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/tray/tray_details_view_unittest.cc
diff --git a/ash/system/tray/tray_details_view_unittest.cc b/ash/system/tray/tray_details_view_unittest.cc
index 32c859a38e9ef62ffd4a55044062e03e0a1a5ef0..3430c76cb573ac3b11175a59862c4c0d15fdef55 100644
--- a/ash/system/tray/tray_details_view_unittest.cc
+++ b/ash/system/tray/tray_details_view_unittest.cc
@@ -8,14 +8,19 @@
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/system/status_area_widget.h"
+#include "ash/system/tray/hover_highlight_view.h"
+#include "ash/system/tray/special_popup_row.h"
#include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_item.h"
#include "ash/system/tray/tray_details_view.h"
#include "ash/system/tray/view_click_listener.h"
#include "ash/test/ash_test_base.h"
+#include "base/command_line.h"
#include "base/run_loop.h"
#include "grit/ash_strings.h"
#include "ui/aura/window.h"
+#include "ui/base/ui_base_switches.h"
+#include "ui/events/test/event_generator.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
@@ -31,14 +36,15 @@ SystemTray* GetSystemTray() {
class TestDetailsView : public TrayDetailsView, public ViewClickListener {
public:
- explicit TestDetailsView(SystemTrayItem* owner) : TrayDetailsView(owner) {}
-
- virtual ~TestDetailsView() {}
-
- void CreateFooterAndFocus() {
+ explicit TestDetailsView(SystemTrayItem* owner) : TrayDetailsView(owner) {
// Uses bluetooth label for testing purpose. It can be changed to any
// string_id.
CreateSpecialRow(IDS_ASH_STATUS_TRAY_BLUETOOTH, this);
+ }
+
+ virtual ~TestDetailsView() {}
+
+ void FocusFooter() {
footer()->content()->RequestFocus();
}
@@ -92,7 +98,33 @@ class TestItem : public SystemTrayItem {
} // namespace
-typedef AshTestBase TrayDetailsViewTest;
+class TrayDetailsViewTest : public AshTestBase {
+ public:
+ TrayDetailsViewTest() {}
+ virtual ~TrayDetailsViewTest() {}
+
+ HoverHighlightView* CreateAndShowHoverHighlightView() {
+ SystemTray* tray = GetSystemTray();
+ TestItem* test_item = new TestItem;
+ tray->AddTrayItem(test_item);
+ tray->ShowDefaultView(BUBBLE_CREATE_NEW);
+ RunAllPendingInMessageLoop();
+ tray->ShowDetailedView(test_item, 0, true, BUBBLE_USE_EXISTING);
+ RunAllPendingInMessageLoop();
+
+ return static_cast<HoverHighlightView*>(test_item->detailed_view()->
+ footer()->content());
+ }
+
+ virtual void SetUp() OVERRIDE {
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kEnableTouchFeedback);
+ test::AshTestBase::SetUp();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TrayDetailsViewTest);
+};
TEST_F(TrayDetailsViewTest, TransitionToDefaultViewTest) {
SystemTray* tray = GetSystemTray();
@@ -119,7 +151,7 @@ TEST_F(TrayDetailsViewTest, TransitionToDefaultViewTest) {
// Transition back to default view, the default view of item 2 should have
// focus.
- test_item_2->detailed_view()->CreateFooterAndFocus();
+ test_item_2->detailed_view()->FocusFooter();
test_item_2->detailed_view()->TransitionToDefaultView();
RunAllPendingInMessageLoop();
@@ -143,5 +175,44 @@ TEST_F(TrayDetailsViewTest, TransitionToDefaultViewTest) {
EXPECT_FALSE(test_item_2->default_view()->HasFocus());
}
+// Tests that HoverHighlightView enters hover state in response to touch.
+TEST_F(TrayDetailsViewTest, HoverHighlightViewTouchFeedback) {
+ HoverHighlightView* view = CreateAndShowHoverHighlightView();
+ EXPECT_FALSE(view->hover());
+
+ ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
+ generator.set_current_location(view->GetBoundsInScreen().CenterPoint());
+ generator.PressTouch();
+ RunAllPendingInMessageLoop();
+ EXPECT_TRUE(view->hover());
+
+ generator.ReleaseTouch();
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(view->hover());
+}
+
+// Tests that touch events leaving HoverHighlightView cancel the hover state.
+TEST_F(TrayDetailsViewTest, HoverHighlightViewTouchFeedbackCancellation) {
+ HoverHighlightView* view = CreateAndShowHoverHighlightView();
+ EXPECT_FALSE(view->hover());
+
+ 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->hover());
+
+ gfx::Point move_point(view_bounds.x(), view_bounds.CenterPoint().y());
+ generator.MoveTouch(move_point);
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(view->hover());
+
+ generator.set_current_location(move_point);
+ generator.ReleaseTouch();
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(view->hover());
+}
+
} // namespace test
} // namespace ash
« no previous file with comments | « ash/system/tray/system_tray_unittest.cc ('k') | ash/system/tray/tray_popup_item_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698