| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 std::string()); | 284 std::string()); |
| 285 updater.Init(); | 285 updater.Init(); |
| 286 | 286 |
| 287 // There should be one more item. | 287 // There should be one more item. |
| 288 ASSERT_EQ(initial_size + 1, launcher_model_->items().size()); | 288 ASSERT_EQ(initial_size + 1, launcher_model_->items().size()); |
| 289 // New item should be added at the end. | 289 // New item should be added at the end. |
| 290 EXPECT_EQ(ash::TYPE_TABBED, GetItem(&updater).type); | 290 EXPECT_EQ(ash::TYPE_TABBED, GetItem(&updater).type); |
| 291 } | 291 } |
| 292 } | 292 } |
| 293 | 293 |
| 294 // Verifies Panels items work. | |
| 295 TEST_F(BrowserLauncherItemControllerTest, PanelItem) { | |
| 296 size_t initial_size = launcher_model_->items().size(); | |
| 297 | |
| 298 // Add an App panel. | |
| 299 { | |
| 300 aura::Window window(NULL); | |
| 301 TabHelperTabStripModelDelegate tab_strip_delegate; | |
| 302 TabStripModel tab_strip(&tab_strip_delegate, profile()); | |
| 303 scoped_ptr<content::WebContents> panel_tab(CreateTestWebContents()); | |
| 304 app_tab_helper_->SetAppID(panel_tab.get(), "1"); // Panels are apps. | |
| 305 tab_strip.InsertWebContentsAt(0, | |
| 306 panel_tab.get(), | |
| 307 TabStripModel::ADD_ACTIVE); | |
| 308 BrowserLauncherItemController updater( | |
| 309 LauncherItemController::TYPE_APP_PANEL, | |
| 310 &window, &tab_strip, launcher_delegate_.get(), | |
| 311 std::string()); | |
| 312 updater.Init(); | |
| 313 ASSERT_EQ(initial_size + 1, launcher_model_->items().size()); | |
| 314 EXPECT_EQ(ash::TYPE_APP_PANEL, GetItem(&updater).type); | |
| 315 EXPECT_EQ(static_cast<void*>(NULL), updater.favicon_loader_.get()); | |
| 316 } | |
| 317 | |
| 318 // Add an Extension panel. | |
| 319 { | |
| 320 aura::Window window(NULL); | |
| 321 TabHelperTabStripModelDelegate tab_strip_delegate; | |
| 322 TabStripModel tab_strip(&tab_strip_delegate, profile()); | |
| 323 scoped_ptr<content::WebContents> panel_tab(CreateTestWebContents()); | |
| 324 app_tab_helper_->SetAppID(panel_tab.get(), "1"); // Panels are apps. | |
| 325 tab_strip.InsertWebContentsAt(0, | |
| 326 panel_tab.get(), | |
| 327 TabStripModel::ADD_ACTIVE); | |
| 328 BrowserLauncherItemController updater( | |
| 329 LauncherItemController::TYPE_EXTENSION_PANEL, | |
| 330 &window, &tab_strip, launcher_delegate_.get(), | |
| 331 std::string()); | |
| 332 updater.Init(); | |
| 333 ASSERT_EQ(initial_size + 1, launcher_model_->items().size()); | |
| 334 EXPECT_EQ(ash::TYPE_PLATFORM_APP, GetItem(&updater).type); | |
| 335 EXPECT_NE(static_cast<void*>(NULL), updater.favicon_loader_.get()); | |
| 336 } | |
| 337 } | |
| 338 | |
| 339 // Verifies pinned apps are persisted and restored. | 294 // Verifies pinned apps are persisted and restored. |
| 340 TEST_F(BrowserLauncherItemControllerTest, PersistPinned) { | 295 TEST_F(BrowserLauncherItemControllerTest, PersistPinned) { |
| 341 size_t initial_size = launcher_model_->items().size(); | 296 size_t initial_size = launcher_model_->items().size(); |
| 342 scoped_ptr<content::WebContents> tab1(CreateTestWebContents()); | 297 scoped_ptr<content::WebContents> tab1(CreateTestWebContents()); |
| 343 | 298 |
| 344 app_tab_helper_->SetAppID(tab1.get(), "1"); | 299 app_tab_helper_->SetAppID(tab1.get(), "1"); |
| 345 | 300 |
| 346 app_icon_loader_->GetAndClearFetchCount(); | 301 app_icon_loader_->GetAndClearFetchCount(); |
| 347 launcher_delegate_->PinAppWithID("1"); | 302 launcher_delegate_->PinAppWithID("1"); |
| 348 EXPECT_GT(app_icon_loader_->GetAndClearFetchCount(), 0); | 303 EXPECT_GT(app_icon_loader_->GetAndClearFetchCount(), 0); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 EXPECT_EQ(ash::STATUS_RUNNING, app_state.GetUpdaterItem().status); | 406 EXPECT_EQ(ash::STATUS_RUNNING, app_state.GetUpdaterItem().status); |
| 452 | 407 |
| 453 // App window should go to attention state. | 408 // App window should go to attention state. |
| 454 app_state.window.SetProperty(aura::client::kDrawAttentionKey, true); | 409 app_state.window.SetProperty(aura::client::kDrawAttentionKey, true); |
| 455 EXPECT_EQ(ash::STATUS_ATTENTION, app_state.GetUpdaterItem().status); | 410 EXPECT_EQ(ash::STATUS_ATTENTION, app_state.GetUpdaterItem().status); |
| 456 | 411 |
| 457 // Activating app window should clear attention state. | 412 // Activating app window should clear attention state. |
| 458 activation_client_->ActivateWindow(&app_state.window); | 413 activation_client_->ActivateWindow(&app_state.window); |
| 459 EXPECT_EQ(ash::STATUS_ACTIVE, app_state.GetUpdaterItem().status); | 414 EXPECT_EQ(ash::STATUS_ACTIVE, app_state.GetUpdaterItem().status); |
| 460 } | 415 } |
| OLD | NEW |