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

Unified Diff: athena/home/home_card_unittest.cc

Issue 512963002: Clears focus on gesture event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years, 4 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 | « athena/home/home_card_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/home/home_card_unittest.cc
diff --git a/athena/home/home_card_unittest.cc b/athena/home/home_card_unittest.cc
index 63653051696bbf0a091b2ce6515aaeab72fb686d..46a32514aeaaadff77d97dc5d9d1f6167470b833 100644
--- a/athena/home/home_card_unittest.cc
+++ b/athena/home/home_card_unittest.cc
@@ -14,6 +14,9 @@
#include "ui/events/test/event_generator.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
+#include "ui/views/controls/textfield/textfield.h"
+#include "ui/views/focus/focus_manager.h"
+#include "ui/views/widget/widget.h"
namespace athena {
@@ -22,6 +25,12 @@ aura::Window* GetHomeCardWindow() {
GetHomeCardWindowForTest();
}
+// Returns true if the keyboard focus is on the search box.
+bool IsSearchBoxFocused(aura::Window* home_card) {
+ return views::Widget::GetWidgetForNativeWindow(home_card)->
+ GetContentsView()->GetViewByID(kHomeCardSearchBoxId)->HasFocus();
+}
+
typedef test::AthenaTestBase HomeCardTest;
TEST_F(HomeCardTest, BasicTransition) {
@@ -220,4 +229,33 @@ TEST_F(HomeCardTest, GesturesToFullDirectly) {
EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive());
}
+TEST_F(HomeCardTest, KeyboardFocus) {
+ ASSERT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState());
+ aura::Window* home_card = GetHomeCardWindow();
+ ASSERT_FALSE(IsSearchBoxFocused(home_card));
+
+ WindowManager::GetInstance()->ToggleOverview();
+ ASSERT_FALSE(IsSearchBoxFocused(home_card));
+
+ ui::test::EventGenerator generator(root_window());
+ gfx::Rect screen_rect(root_window()->bounds());
+
+ const int bottom = screen_rect.bottom();
+ const int x = screen_rect.x() + 1;
+
+ generator.GestureScrollSequence(gfx::Point(x, bottom - 40),
+ gfx::Point(x, 10),
+ base::TimeDelta::FromSeconds(1),
+ 10);
+ EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState());
+ EXPECT_TRUE(IsSearchBoxFocused(home_card));
+
+ generator.GestureScrollSequence(gfx::Point(x, 10),
+ gfx::Point(x, bottom - 100),
+ base::TimeDelta::FromSeconds(1),
+ 10);
+ EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState());
+ EXPECT_FALSE(IsSearchBoxFocused(home_card));
+}
+
} // namespace athena
« no previous file with comments | « athena/home/home_card_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698