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 20184aaaec72a089cfc1af40ba4b788be346eeed..457fc273032cb078ae80c5234f3d906f4f0aacc7 100644 |
--- a/ash/wm/overview/window_selector_unittest.cc |
+++ b/ash/wm/overview/window_selector_unittest.cc |
@@ -8,6 +8,7 @@ |
#include "ash/shelf/shelf.h" |
#include "ash/shelf/shelf_widget.h" |
#include "ash/shell.h" |
+#include "ash/shell_window_ids.h" |
#include "ash/test/ash_test_base.h" |
#include "ash/test/shelf_test_api.h" |
#include "ash/test/shelf_view_test_api.h" |
@@ -16,6 +17,7 @@ |
#include "ash/wm/mru_window_tracker.h" |
#include "ash/wm/overview/window_selector.h" |
#include "ash/wm/overview/window_selector_controller.h" |
+#include "ash/wm/overview/window_selector_item.h" |
#include "ash/wm/window_state.h" |
#include "ash/wm/window_util.h" |
#include "ash/wm/wm_event.h" |
@@ -35,6 +37,8 @@ |
#include "ui/compositor/scoped_animation_duration_scale_mode.h" |
#include "ui/gfx/rect_conversions.h" |
#include "ui/gfx/transform.h" |
+#include "ui/views/controls/label.h" |
+#include "ui/views/widget/native_widget_aura.h" |
#include "ui/wm/core/window_util.h" |
#include "ui/wm/public/activation_delegate.h" |
@@ -225,6 +229,15 @@ class WindowSelectorTest : public test::AshTestBase { |
aura::Window* GetFocusedWindow() { |
return aura::client::GetFocusClient( |
Shell::GetPrimaryRootWindow())->GetFocusedWindow(); |
+ } |
+ |
+ ScopedVector<WindowSelectorItem>* GetWindowItems() { |
+ return &(ash::Shell::GetInstance()->window_selector_controller()-> |
+ window_selector_->windows_); |
+ } |
+ |
+ views::Widget* GetLabelWidget(ash::WindowSelectorItem* window) { |
+ return window->window_label_.get(); |
} |
test::ShelfViewTestAPI* shelf_view_test() { |
@@ -1087,4 +1100,43 @@ TEST_F(WindowSelectorTest, HitTestingInOverview) { |
} |
} |
+// Test that a label is created under the window on entering overview mode. |
+TEST_F(WindowSelectorTest, CreateLabelUnderWindow) { |
+ scoped_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 100, 100))); |
+ base::string16 window_title = base::UTF8ToUTF16("My window"); |
+ window->set_title(window_title); |
+ ToggleOverview(); |
+ WindowSelectorItem* window_item = GetWindowItems()->back(); |
+ views::Widget* widget = GetLabelWidget(window_item); |
+ // Has the label widget been created? |
+ ASSERT_TRUE(widget); |
+ views::Label* label = static_cast<views::Label*>(widget->GetContentsView()); |
+ // Verify the label matches the window title. |
+ EXPECT_EQ(label->text(), window_title); |
+ // Labels are located based on target_bounds, not the actual window item |
+ // bounds. |
+ gfx::Rect target_bounds(window_item->target_bounds()); |
+ gfx::Rect expected_label_bounds(target_bounds.x(), |
+ target_bounds.y() + target_bounds.height(), |
+ target_bounds.width(), |
+ 20); |
+ gfx::Rect real_label_bounds = widget->GetNativeWindow()->bounds(); |
+ EXPECT_EQ(widget->GetNativeWindow()->bounds(), real_label_bounds); |
+} |
+ |
+// Test that a label is created under the panel on entering overview mode. |
flackr
2014/04/17 03:44:29
I think the only thing that's special about panels
Nina
2014/04/17 15:02:19
Done.
|
+TEST_F(WindowSelectorTest, CreateLabelUnderPanel) { |
+ scoped_ptr<aura::Window> window(CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); |
+ base::string16 window_title = base::UTF8ToUTF16("My panel"); |
+ window->set_title(window_title); |
+ ToggleOverview(); |
+ WindowSelectorItem* window_item = GetWindowItems()->back(); |
+ views::Widget* widget = GetLabelWidget(window_item); |
+ // Has the label widget been created? |
+ ASSERT_TRUE(widget); |
+ views::Label* label = static_cast<views::Label*>(widget->GetContentsView()); |
+ // Verify the label matches the window title. |
+ EXPECT_EQ(label->text(), window_title); |
+} |
+ |
} // namespace ash |