| 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 "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 257 |
| 258 private: | 258 private: |
| 259 DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController); | 259 DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController); |
| 260 }; | 260 }; |
| 261 | 261 |
| 262 } // namespace | 262 } // namespace |
| 263 | 263 |
| 264 class ChromeLauncherControllerTest : public BrowserWithTestWindowTest { | 264 class ChromeLauncherControllerTest : public BrowserWithTestWindowTest { |
| 265 protected: | 265 protected: |
| 266 ChromeLauncherControllerTest() | 266 ChromeLauncherControllerTest() |
| 267 : BrowserWithTestWindowTest( | 267 : BrowserWithTestWindowTest(Browser::TYPE_TABBED, |
| 268 Browser::TYPE_TABBED, | 268 ui::HOST_DESKTOP_TYPE_ASH, |
| 269 chrome::HOST_DESKTOP_TYPE_ASH, | 269 false), |
| 270 false), | |
| 271 test_controller_(NULL), | 270 test_controller_(NULL), |
| 272 extension_service_(NULL) { | 271 extension_service_(NULL) {} |
| 273 } | |
| 274 | 272 |
| 275 ~ChromeLauncherControllerTest() override {} | 273 ~ChromeLauncherControllerTest() override {} |
| 276 | 274 |
| 277 void SetUp() override { | 275 void SetUp() override { |
| 278 BrowserWithTestWindowTest::SetUp(); | 276 BrowserWithTestWindowTest::SetUp(); |
| 279 | 277 |
| 280 model_.reset(new ash::ShelfModel); | 278 model_.reset(new ash::ShelfModel); |
| 281 model_observer_.reset(new TestShelfModelObserver); | 279 model_observer_.reset(new TestShelfModelObserver); |
| 282 model_->AddObserver(model_observer_.get()); | 280 model_->AddObserver(model_observer_.get()); |
| 283 | 281 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 } | 429 } |
| 432 | 430 |
| 433 BrowserWindow* CreateBrowserWindow() override { | 431 BrowserWindow* CreateBrowserWindow() override { |
| 434 return CreateTestBrowserWindowAura(); | 432 return CreateTestBrowserWindowAura(); |
| 435 } | 433 } |
| 436 | 434 |
| 437 scoped_ptr<Browser> CreateBrowserWithTestWindowForProfile(Profile* profile) { | 435 scoped_ptr<Browser> CreateBrowserWithTestWindowForProfile(Profile* profile) { |
| 438 TestBrowserWindow* browser_widnow = CreateTestBrowserWindowAura(); | 436 TestBrowserWindow* browser_widnow = CreateTestBrowserWindowAura(); |
| 439 new TestBrowserWindowOwner(browser_widnow); | 437 new TestBrowserWindowOwner(browser_widnow); |
| 440 return make_scoped_ptr(CreateBrowser(profile, Browser::TYPE_TABBED, false, | 438 return make_scoped_ptr(CreateBrowser(profile, Browser::TYPE_TABBED, false, |
| 441 chrome::HOST_DESKTOP_TYPE_ASH, | 439 ui::HOST_DESKTOP_TYPE_ASH, |
| 442 browser_widnow)); | 440 browser_widnow)); |
| 443 } | 441 } |
| 444 | 442 |
| 445 void AddAppListLauncherItem() { | 443 void AddAppListLauncherItem() { |
| 446 ash::ShelfItem app_list; | 444 ash::ShelfItem app_list; |
| 447 app_list.type = ash::TYPE_APP_LIST; | 445 app_list.type = ash::TYPE_APP_LIST; |
| 448 model_->Add(app_list); | 446 model_->Add(app_list); |
| 449 } | 447 } |
| 450 | 448 |
| 451 void InitLauncherController() { | 449 void InitLauncherController() { |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 V1App(Profile* profile, const std::string& app_name) { | 680 V1App(Profile* profile, const std::string& app_name) { |
| 683 // Create a window. | 681 // Create a window. |
| 684 native_window_.reset(new aura::Window(NULL)); | 682 native_window_.reset(new aura::Window(NULL)); |
| 685 native_window_->set_id(0); | 683 native_window_->set_id(0); |
| 686 native_window_->SetType(ui::wm::WINDOW_TYPE_POPUP); | 684 native_window_->SetType(ui::wm::WINDOW_TYPE_POPUP); |
| 687 native_window_->Init(ui::LAYER_TEXTURED); | 685 native_window_->Init(ui::LAYER_TEXTURED); |
| 688 native_window_->Show(); | 686 native_window_->Show(); |
| 689 aura::client::ParentWindowWithContext(native_window_.get(), | 687 aura::client::ParentWindowWithContext(native_window_.get(), |
| 690 ash::Shell::GetPrimaryRootWindow(), | 688 ash::Shell::GetPrimaryRootWindow(), |
| 691 gfx::Rect(10, 10, 20, 30)); | 689 gfx::Rect(10, 10, 20, 30)); |
| 692 Browser::CreateParams params = | 690 Browser::CreateParams params = Browser::CreateParams::CreateForApp( |
| 693 Browser::CreateParams::CreateForApp(kCrxAppPrefix + app_name, | 691 kCrxAppPrefix + app_name, true /* trusted_source */, gfx::Rect(), |
| 694 true /* trusted_source */, | 692 profile, ui::HOST_DESKTOP_TYPE_ASH); |
| 695 gfx::Rect(), | |
| 696 profile, | |
| 697 chrome::HOST_DESKTOP_TYPE_ASH); | |
| 698 params.window = this; | 693 params.window = this; |
| 699 browser_.reset(new Browser(params)); | 694 browser_.reset(new Browser(params)); |
| 700 chrome::AddTabAt(browser_.get(), GURL(), 0, true); | 695 chrome::AddTabAt(browser_.get(), GURL(), 0, true); |
| 701 } | 696 } |
| 702 | 697 |
| 703 ~V1App() override { | 698 ~V1App() override { |
| 704 // close all tabs. Note that we do not need to destroy the browser itself. | 699 // close all tabs. Note that we do not need to destroy the browser itself. |
| 705 browser_->tab_strip_model()->CloseAllTabs(); | 700 browser_->tab_strip_model()->CloseAllTabs(); |
| 706 } | 701 } |
| 707 | 702 |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1461 | 1456 |
| 1462 // Create a second test profile. The first is the one in profile() created in | 1457 // Create a second test profile. The first is the one in profile() created in |
| 1463 // BrowserWithTestWindowTest::SetUp(). | 1458 // BrowserWithTestWindowTest::SetUp(). |
| 1464 // No need to add the profiles to the MultiUserWindowManager here. | 1459 // No need to add the profiles to the MultiUserWindowManager here. |
| 1465 // CreateMultiUserProfile() already does that. | 1460 // CreateMultiUserProfile() already does that. |
| 1466 TestingProfile* profile2 = CreateMultiUserProfile("user2"); | 1461 TestingProfile* profile2 = CreateMultiUserProfile("user2"); |
| 1467 const std::string& current_user = | 1462 const std::string& current_user = |
| 1468 multi_user_util::GetUserIDFromProfile(profile()); | 1463 multi_user_util::GetUserIDFromProfile(profile()); |
| 1469 | 1464 |
| 1470 // Create a browser window with a native window for the current user. | 1465 // Create a browser window with a native window for the current user. |
| 1471 Browser::CreateParams params(profile(), chrome::HOST_DESKTOP_TYPE_ASH); | 1466 Browser::CreateParams params(profile(), ui::HOST_DESKTOP_TYPE_ASH); |
| 1472 scoped_ptr<Browser> browser( | 1467 scoped_ptr<Browser> browser( |
| 1473 chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, ¶ms)); | 1468 chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, ¶ms)); |
| 1474 BrowserWindow* browser_window = browser->window(); | 1469 BrowserWindow* browser_window = browser->window(); |
| 1475 aura::Window* window = browser_window->GetNativeWindow(); | 1470 aura::Window* window = browser_window->GetNativeWindow(); |
| 1476 manager->SetWindowOwner(window, current_user); | 1471 manager->SetWindowOwner(window, current_user); |
| 1477 | 1472 |
| 1478 // Check that an activation of the window on its owner's desktop does not | 1473 // Check that an activation of the window on its owner's desktop does not |
| 1479 // change the visibility to another user. | 1474 // change the visibility to another user. |
| 1480 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false); | 1475 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false); |
| 1481 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); | 1476 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); |
| (...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2673 | 2668 |
| 2674 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 2669 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 2675 ASSERT_EQ(initial_size + 1, model_->items().size()); | 2670 ASSERT_EQ(initial_size + 1, model_->items().size()); |
| 2676 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 2671 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
| 2677 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 2672 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
| 2678 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); | 2673 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); |
| 2679 | 2674 |
| 2680 launcher_controller_->UnpinAppWithID("1"); | 2675 launcher_controller_->UnpinAppWithID("1"); |
| 2681 ASSERT_EQ(initial_size, model_->items().size()); | 2676 ASSERT_EQ(initial_size, model_->items().size()); |
| 2682 } | 2677 } |
| OLD | NEW |