OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/shelf/shelf_window_watcher.h" | 5 #include "ash/shelf/shelf_window_watcher.h" |
6 | 6 |
7 #include "ash/launcher/launcher_types.h" | 7 #include "ash/launcher/launcher_types.h" |
8 #include "ash/shelf/shelf_model.h" | 8 #include "ash/shelf/shelf_model.h" |
9 #include "ash/shelf/shelf_util.h" | 9 #include "ash/shelf/shelf_util.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
12 #include "ash/test/shell_test_api.h" | 12 #include "ash/test/shell_test_api.h" |
| 13 #include "ash/wm/window_resizer.h" |
13 #include "ash/wm/window_state.h" | 14 #include "ash/wm/window_state.h" |
14 #include "ash/wm/window_util.h" | 15 #include "ash/wm/window_util.h" |
15 #include "ui/aura/client/aura_constants.h" | 16 #include "ui/aura/client/aura_constants.h" |
16 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 18 #include "ui/base/hit_test.h" |
17 | 19 |
18 namespace ash { | 20 namespace ash { |
19 namespace internal { | 21 namespace internal { |
20 | 22 |
21 class ShelfWindowWatcherTest : public test::AshTestBase { | 23 class ShelfWindowWatcherTest : public test::AshTestBase { |
22 public: | 24 public: |
23 ShelfWindowWatcherTest() : model_(NULL) {} | 25 ShelfWindowWatcherTest() : model_(NULL) {} |
24 virtual ~ShelfWindowWatcherTest() {} | 26 virtual ~ShelfWindowWatcherTest() {} |
25 | 27 |
26 virtual void SetUp() OVERRIDE { | 28 virtual void SetUp() OVERRIDE { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 EXPECT_EQ(2, model_->item_count()); | 161 EXPECT_EQ(2, model_->item_count()); |
160 // index and id are not changed after maximizing a window |window|. | 162 // index and id are not changed after maximizing a window |window|. |
161 EXPECT_EQ(index, model_->ItemIndexByID(id)); | 163 EXPECT_EQ(index, model_->ItemIndexByID(id)); |
162 EXPECT_EQ(id, model_->items()[index].id); | 164 EXPECT_EQ(id, model_->items()[index].id); |
163 | 165 |
164 // Restore window |window|. | 166 // Restore window |window|. |
165 window_state->Restore(); | 167 window_state->Restore(); |
166 EXPECT_FALSE(window_state->IsMaximized()); | 168 EXPECT_FALSE(window_state->IsMaximized()); |
167 // No new item is created after restoring a window |window|. | 169 // No new item is created after restoring a window |window|. |
168 EXPECT_EQ(2, model_->item_count()); | 170 EXPECT_EQ(2, model_->item_count()); |
169 // index and id are not changed after maximizing a window |window|. | 171 // Index and id are not changed after maximizing a window |window|. |
170 EXPECT_EQ(index, model_->ItemIndexByID(id)); | 172 EXPECT_EQ(index, model_->ItemIndexByID(id)); |
171 EXPECT_EQ(id, model_->items()[index].id); | 173 EXPECT_EQ(id, model_->items()[index].id); |
172 } | 174 } |
| 175 |
| 176 TEST_F(ShelfWindowWatcherTest, DragWindow) { |
| 177 // ShelfModel only has an APP_LIST item. |
| 178 EXPECT_EQ(1, model_->item_count()); |
| 179 |
| 180 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
| 181 |
| 182 // Create a LauncherItem for |window|. |
| 183 LauncherID id = CreateLauncherItem(window.get()); |
| 184 EXPECT_EQ(2, model_->item_count()); |
| 185 |
| 186 int index = model_->ItemIndexByID(id); |
| 187 EXPECT_EQ(STATUS_RUNNING, model_->items()[index].status); |
| 188 |
| 189 // Simulate dragging of |window|. |
| 190 scoped_ptr<WindowResizer> resizer( |
| 191 CreateWindowResizer(window.get(), |
| 192 gfx::Point(), |
| 193 HTCAPTION, |
| 194 aura::client::WINDOW_MOVE_SOURCE_MOUSE)); |
| 195 ASSERT_TRUE(resizer.get()); |
| 196 resizer->Drag(gfx::Point(50, 50), 0); |
| 197 resizer->CompleteDrag(0); |
| 198 |
| 199 //Index and id are not changed after dragging a |window|. |
| 200 EXPECT_EQ(index, model_->ItemIndexByID(id)); |
| 201 EXPECT_EQ(id, model_->items()[index].id); |
| 202 } |
173 | 203 |
174 } // namespace internal | 204 } // namespace internal |
175 } // namespace ash | 205 } // namespace ash |
OLD | NEW |