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 |
11 #include "ash/ash_switches.h" | 11 #include "ash/ash_switches.h" |
12 #include "ash/shelf/shelf_item_delegate_manager.h" | 12 #include "ash/shelf/shelf_item_delegate_manager.h" |
13 #include "ash/shelf/shelf_model.h" | 13 #include "ash/shelf/shelf_model.h" |
14 #include "ash/shelf/shelf_model_observer.h" | 14 #include "ash/shelf/shelf_model_observer.h" |
15 #include "ash/shell.h" | 15 #include "ash/shell.h" |
16 #include "ash/test/shelf_item_delegate_manager_test_api.h" | 16 #include "ash/test/shelf_item_delegate_manager_test_api.h" |
17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
18 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
19 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
20 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
21 #include "base/message_loop/message_loop.h" | 21 #include "base/message_loop/message_loop.h" |
22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
23 #include "base/values.h" | 23 #include "base/values.h" |
24 #include "chrome/browser/extensions/extension_service.h" | 24 #include "chrome/browser/extensions/extension_service.h" |
25 #include "chrome/browser/extensions/test_extension_system.h" | 25 #include "chrome/browser/extensions/test_extension_system.h" |
26 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" | |
27 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 26 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
28 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" | 27 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" |
29 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" | 28 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" |
30 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 29 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
31 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
32 #include "chrome/browser/ui/browser_commands.h" | 31 #include "chrome/browser/ui/browser_commands.h" |
33 #include "chrome/browser/ui/browser_finder.h" | 32 #include "chrome/browser/ui/browser_finder.h" |
34 #include "chrome/browser/ui/browser_list.h" | 33 #include "chrome/browser/ui/browser_list.h" |
35 #include "chrome/browser/ui/browser_tabstrip.h" | 34 #include "chrome/browser/ui/browser_tabstrip.h" |
36 #include "chrome/browser/ui/host_desktop.h" | 35 #include "chrome/browser/ui/host_desktop.h" |
(...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1985 // the active item is the first entry. | 1984 // the active item is the first entry. |
1986 base::string16 two_menu_items[] = {title1, title2}; | 1985 base::string16 two_menu_items[] = {title1, title2}; |
1987 EXPECT_TRUE(CheckMenuCreation( | 1986 EXPECT_TRUE(CheckMenuCreation( |
1988 launcher_controller_.get(), item_browser, 2, two_menu_items, true)); | 1987 launcher_controller_.get(), item_browser, 2, two_menu_items, true)); |
1989 | 1988 |
1990 // Apparently we have to close all tabs we have. | 1989 // Apparently we have to close all tabs we have. |
1991 chrome::CloseTab(browser2.get()); | 1990 chrome::CloseTab(browser2.get()); |
1992 } | 1991 } |
1993 | 1992 |
1994 #if defined(OS_CHROMEOS) | 1993 #if defined(OS_CHROMEOS) |
1995 static KeyedService* BuildChromeFaviconClient( | |
1996 content::BrowserContext* profile) { | |
1997 return new ChromeFaviconClient(static_cast<Profile*>(profile)); | |
1998 } | |
1999 | |
2000 // Check the multi profile case where only user related browsers should show | 1994 // Check the multi profile case where only user related browsers should show |
2001 // up. | 1995 // up. |
2002 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, | 1996 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, |
2003 BrowserMenuGenerationTwoUsers) { | 1997 BrowserMenuGenerationTwoUsers) { |
2004 // Create a browser item in the LauncherController. | 1998 // Create a browser item in the LauncherController. |
2005 InitLauncherController(); | 1999 InitLauncherController(); |
2006 | 2000 |
2007 ash::ShelfItem item_browser; | 2001 ash::ShelfItem item_browser; |
2008 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; | 2002 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; |
2009 item_browser.id = | 2003 item_browser.id = |
2010 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); | 2004 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); |
2011 | 2005 |
2012 // Check that the menu is empty. | 2006 // Check that the menu is empty. |
2013 chrome::NewTab(browser()); | 2007 chrome::NewTab(browser()); |
2014 EXPECT_TRUE(CheckMenuCreation( | 2008 EXPECT_TRUE(CheckMenuCreation( |
2015 launcher_controller_.get(), item_browser, 0, NULL, true)); | 2009 launcher_controller_.get(), item_browser, 0, NULL, true)); |
2016 | 2010 |
2017 // Show the created |browser()| by adding it to the active browser list. | 2011 // Show the created |browser()| by adding it to the active browser list. |
2018 BrowserList::SetLastActive(browser()); | 2012 BrowserList::SetLastActive(browser()); |
2019 base::string16 title1 = ASCIIToUTF16("Test1"); | 2013 base::string16 title1 = ASCIIToUTF16("Test1"); |
2020 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1); | 2014 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1); |
2021 base::string16 one_menu_item1[] = { title1 }; | 2015 base::string16 one_menu_item1[] = { title1 }; |
2022 EXPECT_TRUE(CheckMenuCreation( | 2016 EXPECT_TRUE(CheckMenuCreation( |
2023 launcher_controller_.get(), item_browser, 1, one_menu_item1, true)); | 2017 launcher_controller_.get(), item_browser, 1, one_menu_item1, true)); |
2024 | 2018 |
2025 // Create a browser for another user and check that it is not included in the | 2019 // Create a browser for another user and check that it is not included in the |
2026 // users running browser list. | 2020 // users running browser list. |
2027 std::string user2 = "user2"; | 2021 std::string user2 = "user2"; |
2028 TestingProfile* profile2 = CreateMultiUserProfile(user2); | 2022 TestingProfile* profile2 = CreateMultiUserProfile(user2); |
2029 ChromeFaviconClientFactory::GetInstance()->SetTestingFactory( | |
2030 profile2, BuildChromeFaviconClient); | |
2031 scoped_ptr<Browser> browser2( | 2023 scoped_ptr<Browser> browser2( |
2032 CreateBrowserAndTabWithProfile(profile2, user2, "http://test2")); | 2024 CreateBrowserAndTabWithProfile(profile2, user2, "http://test2")); |
2033 base::string16 one_menu_item2[] = { ASCIIToUTF16(user2) }; | 2025 base::string16 one_menu_item2[] = { ASCIIToUTF16(user2) }; |
2034 EXPECT_TRUE(CheckMenuCreation( | 2026 EXPECT_TRUE(CheckMenuCreation( |
2035 launcher_controller_.get(), item_browser, 1, one_menu_item1, true)); | 2027 launcher_controller_.get(), item_browser, 1, one_menu_item1, true)); |
2036 | 2028 |
2037 // Switch to the other user and make sure that only that browser window gets | 2029 // Switch to the other user and make sure that only that browser window gets |
2038 // shown. | 2030 // shown. |
2039 SwitchActiveUser(profile2->GetProfileName()); | 2031 SwitchActiveUser(profile2->GetProfileName()); |
2040 EXPECT_TRUE(CheckMenuCreation( | 2032 EXPECT_TRUE(CheckMenuCreation( |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2700 | 2692 |
2701 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 2693 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
2702 ASSERT_EQ(initial_size + 1, model_->items().size()); | 2694 ASSERT_EQ(initial_size + 1, model_->items().size()); |
2703 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 2695 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
2704 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 2696 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
2705 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); | 2697 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); |
2706 | 2698 |
2707 launcher_controller_->UnpinAppWithID("1"); | 2699 launcher_controller_->UnpinAppWithID("1"); |
2708 ASSERT_EQ(initial_size, model_->items().size()); | 2700 ASSERT_EQ(initial_size, model_->items().size()); |
2709 } | 2701 } |
OLD | NEW |