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

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: 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/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 50c89c08861d40e1a679ba3c369c865feb24f612..38f81730925ed8652128a6830d236f285f03001b 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,20 @@ class TestItem : public SystemTrayItem {
} // namespace
-typedef AshTestBase TrayDetailsViewTest;
+class TrayDetailsViewTest : public AshTestBase {
+ public:
+ TrayDetailsViewTest() {}
+ virtual ~TrayDetailsViewTest() {}
+
+ 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 +138,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 +162,62 @@ 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) {
+ 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();
+
+ HoverHighlightView* view = static_cast<HoverHighlightView*>(test_item->
+ detailed_view()->footer()->content());
+ 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) {
+ 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();
+
+ HoverHighlightView* view = static_cast<HoverHighlightView*>(test_item->
+ detailed_view()->footer()->content());
Mr4D (OOO till 08-26) 2014/10/07 22:51:45 indent
jonross 2014/10/08 14:18:00 Done.
+ EXPECT_FALSE(view->hover());
Mr4D (OOO till 08-26) 2014/10/07 22:51:45 Nit: The first part of these two tests appear to b
jonross 2014/10/08 14:18:00 Done.
+
+ 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

Powered by Google App Engine
This is Rietveld 408576698