OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 State(BrowserLauncherItemControllerTest* test, | 167 State(BrowserLauncherItemControllerTest* test, |
168 const std::string& app_id, | 168 const std::string& app_id, |
169 BrowserLauncherItemController::Type launcher_type) | 169 BrowserLauncherItemController::Type launcher_type) |
170 : launcher_test(test), | 170 : launcher_test(test), |
171 window(NULL), | 171 window(NULL), |
172 tab_strip(&tab_strip_delegate, test->profile()), | 172 tab_strip(&tab_strip_delegate, test->profile()), |
173 updater(launcher_type, | 173 updater(launcher_type, |
174 &window, | 174 &window, |
175 &tab_strip, | 175 &tab_strip, |
176 test->launcher_delegate_.get(), | 176 test->launcher_delegate_.get(), |
177 app_id) { | 177 app_id, |
| 178 std::string()) { |
178 window.Init(ui::LAYER_NOT_DRAWN); | 179 window.Init(ui::LAYER_NOT_DRAWN); |
179 launcher_test->root_window()->AddChild(&window); | 180 launcher_test->root_window()->AddChild(&window); |
180 launcher_test->activation_client_->ActivateWindow(&window); | 181 launcher_test->activation_client_->ActivateWindow(&window); |
181 aura::client::SetActivationDelegate(&window, this); | 182 aura::client::SetActivationDelegate(&window, this); |
182 aura::client::SetActivationChangeObserver(&window, this); | 183 aura::client::SetActivationChangeObserver(&window, this); |
183 updater.Init(); | 184 updater.Init(); |
184 } | 185 } |
185 | 186 |
186 ash::LauncherItem GetUpdaterItem() { | 187 ash::LauncherItem GetUpdaterItem() { |
187 ash::LauncherID launcher_id = | 188 ash::LauncherID launcher_id = |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 TabStripModel tab_strip(&tab_strip_delegate, profile()); | 275 TabStripModel tab_strip(&tab_strip_delegate, profile()); |
275 tab_strip.InsertWebContentsAt(0, | 276 tab_strip.InsertWebContentsAt(0, |
276 web_contents.get(), | 277 web_contents.get(), |
277 TabStripModel::ADD_ACTIVE); | 278 TabStripModel::ADD_ACTIVE); |
278 aura::Window window(NULL); | 279 aura::Window window(NULL); |
279 window.Init(ui::LAYER_NOT_DRAWN); | 280 window.Init(ui::LAYER_NOT_DRAWN); |
280 root_window()->AddChild(&window); | 281 root_window()->AddChild(&window); |
281 BrowserLauncherItemController updater( | 282 BrowserLauncherItemController updater( |
282 LauncherItemController::TYPE_TABBED, | 283 LauncherItemController::TYPE_TABBED, |
283 &window, &tab_strip, launcher_delegate_.get(), | 284 &window, &tab_strip, launcher_delegate_.get(), |
| 285 std::string(), |
284 std::string()); | 286 std::string()); |
285 updater.Init(); | 287 updater.Init(); |
286 | 288 |
287 // There should be one more item. | 289 // There should be one more item. |
288 ASSERT_EQ(initial_size + 1, launcher_model_->items().size()); | 290 ASSERT_EQ(initial_size + 1, launcher_model_->items().size()); |
289 // New item should be added at the end. | 291 // New item should be added at the end. |
290 EXPECT_EQ(ash::TYPE_TABBED, GetItem(&updater).type); | 292 EXPECT_EQ(ash::TYPE_TABBED, GetItem(&updater).type); |
291 } | 293 } |
292 } | 294 } |
293 | 295 |
294 // Verifies Panels items work. | 296 // Verifies Panels items work. |
295 TEST_F(BrowserLauncherItemControllerTest, PanelItem) { | 297 TEST_F(BrowserLauncherItemControllerTest, PanelItem) { |
296 size_t initial_size = launcher_model_->items().size(); | 298 size_t initial_size = launcher_model_->items().size(); |
297 | 299 |
298 // Add an App panel. | 300 // Add an App panel. |
299 { | 301 { |
300 aura::Window window(NULL); | 302 aura::Window window(NULL); |
301 TabHelperTabStripModelDelegate tab_strip_delegate; | 303 TabHelperTabStripModelDelegate tab_strip_delegate; |
302 TabStripModel tab_strip(&tab_strip_delegate, profile()); | 304 TabStripModel tab_strip(&tab_strip_delegate, profile()); |
303 scoped_ptr<content::WebContents> panel_tab(CreateTestWebContents()); | 305 scoped_ptr<content::WebContents> panel_tab(CreateTestWebContents()); |
304 app_tab_helper_->SetAppID(panel_tab.get(), "1"); // Panels are apps. | 306 app_tab_helper_->SetAppID(panel_tab.get(), "1"); // Panels are apps. |
305 tab_strip.InsertWebContentsAt(0, | 307 tab_strip.InsertWebContentsAt(0, |
306 panel_tab.get(), | 308 panel_tab.get(), |
307 TabStripModel::ADD_ACTIVE); | 309 TabStripModel::ADD_ACTIVE); |
308 BrowserLauncherItemController updater( | 310 BrowserLauncherItemController updater( |
309 LauncherItemController::TYPE_APP_PANEL, | 311 LauncherItemController::TYPE_APP_PANEL, |
310 &window, &tab_strip, launcher_delegate_.get(), | 312 &window, &tab_strip, launcher_delegate_.get(), |
| 313 std::string(), |
311 std::string()); | 314 std::string()); |
312 updater.Init(); | 315 updater.Init(); |
313 ASSERT_EQ(initial_size + 1, launcher_model_->items().size()); | 316 ASSERT_EQ(initial_size + 1, launcher_model_->items().size()); |
314 EXPECT_EQ(ash::TYPE_APP_PANEL, GetItem(&updater).type); | 317 EXPECT_EQ(ash::TYPE_APP_PANEL, GetItem(&updater).type); |
315 EXPECT_EQ(static_cast<void*>(NULL), updater.favicon_loader_.get()); | 318 EXPECT_EQ(static_cast<void*>(NULL), updater.favicon_loader_.get()); |
316 } | 319 } |
317 | 320 |
318 // Add an Extension panel. | 321 // Add an Extension panel. |
319 { | 322 { |
320 aura::Window window(NULL); | 323 aura::Window window(NULL); |
321 TabHelperTabStripModelDelegate tab_strip_delegate; | 324 TabHelperTabStripModelDelegate tab_strip_delegate; |
322 TabStripModel tab_strip(&tab_strip_delegate, profile()); | 325 TabStripModel tab_strip(&tab_strip_delegate, profile()); |
323 scoped_ptr<content::WebContents> panel_tab(CreateTestWebContents()); | 326 scoped_ptr<content::WebContents> panel_tab(CreateTestWebContents()); |
324 app_tab_helper_->SetAppID(panel_tab.get(), "1"); // Panels are apps. | 327 app_tab_helper_->SetAppID(panel_tab.get(), "1"); // Panels are apps. |
325 tab_strip.InsertWebContentsAt(0, | 328 tab_strip.InsertWebContentsAt(0, |
326 panel_tab.get(), | 329 panel_tab.get(), |
327 TabStripModel::ADD_ACTIVE); | 330 TabStripModel::ADD_ACTIVE); |
328 BrowserLauncherItemController updater( | 331 BrowserLauncherItemController updater( |
329 LauncherItemController::TYPE_EXTENSION_PANEL, | 332 LauncherItemController::TYPE_EXTENSION_PANEL, |
330 &window, &tab_strip, launcher_delegate_.get(), | 333 &window, &tab_strip, launcher_delegate_.get(), |
| 334 std::string(), |
331 std::string()); | 335 std::string()); |
332 updater.Init(); | 336 updater.Init(); |
333 ASSERT_EQ(initial_size + 1, launcher_model_->items().size()); | 337 ASSERT_EQ(initial_size + 1, launcher_model_->items().size()); |
334 EXPECT_EQ(ash::TYPE_PLATFORM_APP, GetItem(&updater).type); | 338 EXPECT_EQ(ash::TYPE_PLATFORM_APP, GetItem(&updater).type); |
335 EXPECT_NE(static_cast<void*>(NULL), updater.favicon_loader_.get()); | 339 EXPECT_NE(static_cast<void*>(NULL), updater.favicon_loader_.get()); |
336 } | 340 } |
337 } | 341 } |
338 | 342 |
339 // Verifies pinned apps are persisted and restored. | 343 // Verifies pinned apps are persisted and restored. |
340 TEST_F(BrowserLauncherItemControllerTest, PersistPinned) { | 344 TEST_F(BrowserLauncherItemControllerTest, PersistPinned) { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 EXPECT_EQ(ash::STATUS_RUNNING, app_state.GetUpdaterItem().status); | 455 EXPECT_EQ(ash::STATUS_RUNNING, app_state.GetUpdaterItem().status); |
452 | 456 |
453 // App window should go to attention state. | 457 // App window should go to attention state. |
454 app_state.window.SetProperty(aura::client::kDrawAttentionKey, true); | 458 app_state.window.SetProperty(aura::client::kDrawAttentionKey, true); |
455 EXPECT_EQ(ash::STATUS_ATTENTION, app_state.GetUpdaterItem().status); | 459 EXPECT_EQ(ash::STATUS_ATTENTION, app_state.GetUpdaterItem().status); |
456 | 460 |
457 // Activating app window should clear attention state. | 461 // Activating app window should clear attention state. |
458 activation_client_->ActivateWindow(&app_state.window); | 462 activation_client_->ActivateWindow(&app_state.window); |
459 EXPECT_EQ(ash::STATUS_ACTIVE, app_state.GetUpdaterItem().status); | 463 EXPECT_EQ(ash::STATUS_ACTIVE, app_state.GetUpdaterItem().status); |
460 } | 464 } |
OLD | NEW |