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/launcher/launcher_model.h" | 10 #include "ash/launcher/launcher_model.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 // TODO(avi): Kill this when TabContents goes away. | 30 // TODO(avi): Kill this when TabContents goes away. |
31 class BrowserLauncherItemControllerContentsCreator { | 31 class BrowserLauncherItemControllerContentsCreator { |
32 public: | 32 public: |
33 static TabContents* CreateTabContents(content::WebContents* contents) { | 33 static TabContents* CreateTabContents(content::WebContents* contents) { |
34 return TabContents::Factory::CreateTabContents(contents); | 34 return TabContents::Factory::CreateTabContents(contents); |
35 } | 35 } |
36 }; | 36 }; |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
| 40 const int kExpectedAppIndex = 2; |
| 41 |
40 // Test implementation of AppTabHelper | 42 // Test implementation of AppTabHelper |
41 class AppTabHelperImpl : public ChromeLauncherController::AppTabHelper { | 43 class AppTabHelperImpl : public ChromeLauncherController::AppTabHelper { |
42 public: | 44 public: |
43 AppTabHelperImpl() {} | 45 AppTabHelperImpl() {} |
44 virtual ~AppTabHelperImpl() {} | 46 virtual ~AppTabHelperImpl() {} |
45 | 47 |
46 // Sets the id for the specified tab. The id is removed if Remove() is | 48 // Sets the id for the specified tab. The id is removed if Remove() is |
47 // invoked. | 49 // invoked. |
48 void SetAppID(TabContents* tab, const std::string& id) { | 50 void SetAppID(TabContents* tab, const std::string& id) { |
49 tab_id_map_[tab] = id; | 51 tab_id_map_[tab] = id; |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 scoped_ptr<TabContents> tab1( | 322 scoped_ptr<TabContents> tab1( |
321 BrowserLauncherItemControllerContentsCreator::CreateTabContents( | 323 BrowserLauncherItemControllerContentsCreator::CreateTabContents( |
322 CreateTestWebContents())); | 324 CreateTestWebContents())); |
323 | 325 |
324 app_tab_helper_->SetAppID(tab1.get(), "1"); | 326 app_tab_helper_->SetAppID(tab1.get(), "1"); |
325 | 327 |
326 app_icon_loader_->GetAndClearFetchCount(); | 328 app_icon_loader_->GetAndClearFetchCount(); |
327 launcher_delegate_->PinAppWithID("1"); | 329 launcher_delegate_->PinAppWithID("1"); |
328 EXPECT_GT(app_icon_loader_->GetAndClearFetchCount(), 0); | 330 EXPECT_GT(app_icon_loader_->GetAndClearFetchCount(), 0); |
329 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, | 331 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, |
330 launcher_model_->items()[1].type); | 332 launcher_model_->items()[kExpectedAppIndex].type); |
331 EXPECT_TRUE(launcher_delegate_->IsAppPinned("1")); | 333 EXPECT_TRUE(launcher_delegate_->IsAppPinned("1")); |
332 EXPECT_FALSE(launcher_delegate_->IsAppPinned("0")); | 334 EXPECT_FALSE(launcher_delegate_->IsAppPinned("0")); |
333 EXPECT_EQ(initial_size + 1, launcher_model_->items().size()); | 335 EXPECT_EQ(initial_size + 1, launcher_model_->items().size()); |
334 | 336 |
335 launcher_delegate_.reset( | 337 launcher_delegate_.reset( |
336 new ChromeLauncherController(profile(), launcher_model_.get())); | 338 new ChromeLauncherController(profile(), launcher_model_.get())); |
337 app_tab_helper_ = new AppTabHelperImpl; | 339 app_tab_helper_ = new AppTabHelperImpl; |
338 app_tab_helper_->SetAppID(tab1.get(), "1"); | 340 app_tab_helper_->SetAppID(tab1.get(), "1"); |
339 ResetAppTabHelper(); | 341 ResetAppTabHelper(); |
340 app_icon_loader_ = new AppIconLoaderImpl; | 342 app_icon_loader_ = new AppIconLoaderImpl; |
341 ResetAppIconLoader(); | 343 ResetAppIconLoader(); |
342 launcher_delegate_->Init(); | 344 launcher_delegate_->Init(); |
343 EXPECT_GT(app_icon_loader_->GetAndClearFetchCount(), 0); | 345 EXPECT_GT(app_icon_loader_->GetAndClearFetchCount(), 0); |
344 ASSERT_EQ(initial_size + 1, launcher_model_->items().size()); | 346 ASSERT_EQ(initial_size + 1, launcher_model_->items().size()); |
345 EXPECT_TRUE(launcher_delegate_->IsAppPinned("1")); | 347 EXPECT_TRUE(launcher_delegate_->IsAppPinned("1")); |
346 EXPECT_FALSE(launcher_delegate_->IsAppPinned("0")); | 348 EXPECT_FALSE(launcher_delegate_->IsAppPinned("0")); |
347 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, | 349 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, |
348 launcher_model_->items()[1].type); | 350 launcher_model_->items()[kExpectedAppIndex].type); |
349 | 351 |
350 UnpinAppsWithID("1"); | 352 UnpinAppsWithID("1"); |
351 ASSERT_EQ(initial_size, launcher_model_->items().size()); | 353 ASSERT_EQ(initial_size, launcher_model_->items().size()); |
352 } | 354 } |
353 | 355 |
354 // Confirm that tabbed browsers handle activation correctly. | 356 // Confirm that tabbed browsers handle activation correctly. |
355 TEST_F(BrowserLauncherItemControllerTest, ActivateBrowsers) { | 357 TEST_F(BrowserLauncherItemControllerTest, ActivateBrowsers) { |
356 State state1(this, std::string(), BrowserLauncherItemController::TYPE_TABBED); | 358 State state1(this, std::string(), BrowserLauncherItemController::TYPE_TABBED); |
357 | 359 |
358 // First browser is active. | 360 // First browser is active. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 EXPECT_EQ(ash::STATUS_RUNNING, app_state.GetUpdaterItem().status); | 432 EXPECT_EQ(ash::STATUS_RUNNING, app_state.GetUpdaterItem().status); |
431 | 433 |
432 // App window should go to attention state. | 434 // App window should go to attention state. |
433 app_state.window.SetProperty(aura::client::kDrawAttentionKey, true); | 435 app_state.window.SetProperty(aura::client::kDrawAttentionKey, true); |
434 EXPECT_EQ(ash::STATUS_ATTENTION, app_state.GetUpdaterItem().status); | 436 EXPECT_EQ(ash::STATUS_ATTENTION, app_state.GetUpdaterItem().status); |
435 | 437 |
436 // Activating app window should clear attention state. | 438 // Activating app window should clear attention state. |
437 activation_client_->ActivateWindow(&app_state.window); | 439 activation_client_->ActivateWindow(&app_state.window); |
438 EXPECT_EQ(ash::STATUS_ACTIVE, app_state.GetUpdaterItem().status); | 440 EXPECT_EQ(ash::STATUS_ACTIVE, app_state.GetUpdaterItem().status); |
439 } | 441 } |
OLD | NEW |