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

Unified Diff: ash/wm/overview/window_selector_unittest.cc

Issue 358553004: Added text filtering to Overview Mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Thanks chrome team for helping me fix the previous patch Created 6 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/wm/overview/window_selector_unittest.cc
diff --git a/ash/wm/overview/window_selector_unittest.cc b/ash/wm/overview/window_selector_unittest.cc
index d482f559848b195747431a06dc112891d329df2f..0e0ea4d196af6305c291174f6fec500f693feda7 100644
--- a/ash/wm/overview/window_selector_unittest.cc
+++ b/ash/wm/overview/window_selector_unittest.cc
@@ -30,6 +30,7 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_vector.h"
#include "base/run_loop.h"
+#include "base/strings/string_piece.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/cursor_client.h"
@@ -224,10 +225,22 @@ class WindowSelectorTest : public test::AshTestBase {
GetCloseButton(window_item)->GetNativeView()))));
}
+ void FilterItems(const base::StringPiece& pattern) {
+ ash::Shell::GetInstance()->
+ window_selector_controller()->window_selector_.get()->
+ ContentsChanged(NULL, base::UTF8ToUTF16(pattern));
+ }
+
test::ShelfViewTestAPI* shelf_view_test() {
return shelf_view_test_.get();
}
+ views::Widget* text_filter_widget() {
+ return ash::Shell::GetInstance()->
+ window_selector_controller()->window_selector_.get()->
+ text_filter_widget_.get();
+ }
+
private:
aura::test::TestWindowDelegate delegate_;
NonActivatableActivationDelegate non_activatable_activation_delegate_;
@@ -266,10 +279,10 @@ TEST_F(WindowSelectorTest, Basic) {
// Hide the cursor before entering overview to test that it will be shown.
aura::client::GetCursorClient(root_window)->HideCursor();
- // In overview mode the windows should no longer overlap and focus should
- // be removed from the window.
+ // In overview mode the windows should no longer overlap and the text filter
+ // widget should be focused.
ToggleOverview();
- EXPECT_EQ(NULL, GetFocusedWindow());
+ EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow());
EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get()));
EXPECT_FALSE(WindowsOverlapping(window1.get(), panel1.get()));
// Panels 1 and 2 should still be overlapping being in a single selector
@@ -294,7 +307,7 @@ TEST_F(WindowSelectorTest, BasicGesture) {
wm::ActivateWindow(window1.get());
EXPECT_EQ(window1.get(), GetFocusedWindow());
ToggleOverview();
- EXPECT_EQ(NULL, GetFocusedWindow());
+ EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow());
aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
window2.get());
generator.GestureTapAt(gfx::ToEnclosingRect(
@@ -502,9 +515,9 @@ TEST_F(WindowSelectorTest, CancelRestoresFocus) {
wm::ActivateWindow(window.get());
EXPECT_EQ(window.get(), GetFocusedWindow());
- // In overview mode, focus should be removed.
+ // In overview mode, the text filter widget should be focused.
ToggleOverview();
- EXPECT_EQ(NULL, GetFocusedWindow());
+ EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow());
// If canceling overview mode, focus should be restored.
ToggleOverview();
@@ -1014,4 +1027,26 @@ TEST_F(WindowSelectorTest, CloseButtonOnPanels) {
EXPECT_FALSE(IsSelecting());
}
+// Creates three windows and tests filtering them by title.
+TEST_F(WindowSelectorTest, BasicTextFiltering) {
+ gfx::Rect bounds(0, 0, 100, 100);
+ scoped_ptr<aura::Window> window2(CreateWindow(bounds));
+ scoped_ptr<aura::Window> window1(CreateWindow(bounds));
+ scoped_ptr<aura::Window> window0(CreateWindow(bounds));
+ base::string16 window2_title = base::UTF8ToUTF16("Test - Wikipedia");
+ base::string16 window1_title = base::UTF8ToUTF16("For those about to test");
+ base::string16 window0_title = base::UTF8ToUTF16("We salute you");
+ window0->set_title(window0_title);
+ window1->set_title(window1_title);
+ window2->set_title(window2_title);
+ ToggleOverview();
+ FilterItems("Test");
+
+ std::vector<WindowSelectorItem*> items = GetWindowItemsForRoot(0);
+
+ EXPECT_TRUE(items[0]->dimmed());
+ EXPECT_FALSE(items[1]->dimmed());
+ EXPECT_FALSE(items[2]->dimmed());
+}
flackr 2014/06/27 20:00:07 Cool, nice and simple! Maybe a few more tests lik
Nina 2014/06/27 22:42:02 There's a v2 of this which you might want to see a
+
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698