Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc

Issue 301613004: Turn FaviconClient into a Keyed service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: touching wood Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/favicon/favicon_tab_helper.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
26 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" 27 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
27 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" 28 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h"
28 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" 29 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h"
29 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" 30 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
30 #include "chrome/browser/ui/browser.h" 31 #include "chrome/browser/ui/browser.h"
31 #include "chrome/browser/ui/browser_commands.h" 32 #include "chrome/browser/ui/browser_commands.h"
32 #include "chrome/browser/ui/browser_finder.h" 33 #include "chrome/browser/ui/browser_finder.h"
33 #include "chrome/browser/ui/browser_list.h" 34 #include "chrome/browser/ui/browser_list.h"
34 #include "chrome/browser/ui/browser_tabstrip.h" 35 #include "chrome/browser/ui/browser_tabstrip.h"
35 #include "chrome/browser/ui/host_desktop.h" 36 #include "chrome/browser/ui/host_desktop.h"
(...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 // the active item is the first entry. 1985 // the active item is the first entry.
1985 base::string16 two_menu_items[] = {title1, title2}; 1986 base::string16 two_menu_items[] = {title1, title2};
1986 EXPECT_TRUE(CheckMenuCreation( 1987 EXPECT_TRUE(CheckMenuCreation(
1987 launcher_controller_.get(), item_browser, 2, two_menu_items, true)); 1988 launcher_controller_.get(), item_browser, 2, two_menu_items, true));
1988 1989
1989 // Apparently we have to close all tabs we have. 1990 // Apparently we have to close all tabs we have.
1990 chrome::CloseTab(browser2.get()); 1991 chrome::CloseTab(browser2.get());
1991 } 1992 }
1992 1993
1993 #if defined(OS_CHROMEOS) 1994 #if defined(OS_CHROMEOS)
1995 static KeyedService* BuildChromeFaviconClient(
1996 content::BrowserContext* profile) {
1997 return new ChromeFaviconClient(static_cast<Profile*>(profile));
1998 }
1999
1994 // Check the multi profile case where only user related browsers should show 2000 // Check the multi profile case where only user related browsers should show
1995 // up. 2001 // up.
1996 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, 2002 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest,
1997 BrowserMenuGenerationTwoUsers) { 2003 BrowserMenuGenerationTwoUsers) {
1998 // Create a browser item in the LauncherController. 2004 // Create a browser item in the LauncherController.
1999 InitLauncherController(); 2005 InitLauncherController();
2000 2006
2001 ash::ShelfItem item_browser; 2007 ash::ShelfItem item_browser;
2002 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; 2008 item_browser.type = ash::TYPE_BROWSER_SHORTCUT;
2003 item_browser.id = 2009 item_browser.id =
2004 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); 2010 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId);
2005 2011
2006 // Check that the menu is empty. 2012 // Check that the menu is empty.
2007 chrome::NewTab(browser()); 2013 chrome::NewTab(browser());
2008 EXPECT_TRUE(CheckMenuCreation( 2014 EXPECT_TRUE(CheckMenuCreation(
2009 launcher_controller_.get(), item_browser, 0, NULL, true)); 2015 launcher_controller_.get(), item_browser, 0, NULL, true));
2010 2016
2011 // Show the created |browser()| by adding it to the active browser list. 2017 // Show the created |browser()| by adding it to the active browser list.
2012 BrowserList::SetLastActive(browser()); 2018 BrowserList::SetLastActive(browser());
2013 base::string16 title1 = ASCIIToUTF16("Test1"); 2019 base::string16 title1 = ASCIIToUTF16("Test1");
2014 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1); 2020 NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1);
2015 base::string16 one_menu_item1[] = { title1 }; 2021 base::string16 one_menu_item1[] = { title1 };
2016 EXPECT_TRUE(CheckMenuCreation( 2022 EXPECT_TRUE(CheckMenuCreation(
2017 launcher_controller_.get(), item_browser, 1, one_menu_item1, true)); 2023 launcher_controller_.get(), item_browser, 1, one_menu_item1, true));
2018 2024
2019 // Create a browser for another user and check that it is not included in the 2025 // Create a browser for another user and check that it is not included in the
2020 // users running browser list. 2026 // users running browser list.
2021 std::string user2 = "user2"; 2027 std::string user2 = "user2";
2022 TestingProfile* profile2 = CreateMultiUserProfile(user2); 2028 TestingProfile* profile2 = CreateMultiUserProfile(user2);
2029 ChromeFaviconClientFactory::GetInstance()->SetTestingFactory(
2030 profile2, BuildChromeFaviconClient);
2023 scoped_ptr<Browser> browser2( 2031 scoped_ptr<Browser> browser2(
2024 CreateBrowserAndTabWithProfile(profile2, user2, "http://test2")); 2032 CreateBrowserAndTabWithProfile(profile2, user2, "http://test2"));
2025 base::string16 one_menu_item2[] = { ASCIIToUTF16(user2) }; 2033 base::string16 one_menu_item2[] = { ASCIIToUTF16(user2) };
2026 EXPECT_TRUE(CheckMenuCreation( 2034 EXPECT_TRUE(CheckMenuCreation(
2027 launcher_controller_.get(), item_browser, 1, one_menu_item1, true)); 2035 launcher_controller_.get(), item_browser, 1, one_menu_item1, true));
2028 2036
2029 // Switch to the other user and make sure that only that browser window gets 2037 // Switch to the other user and make sure that only that browser window gets
2030 // shown. 2038 // shown.
2031 SwitchActiveUser(profile2->GetProfileName()); 2039 SwitchActiveUser(profile2->GetProfileName());
2032 EXPECT_TRUE(CheckMenuCreation( 2040 EXPECT_TRUE(CheckMenuCreation(
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
2692 2700
2693 EXPECT_EQ(1, app_icon_loader->fetch_count()); 2701 EXPECT_EQ(1, app_icon_loader->fetch_count());
2694 ASSERT_EQ(initial_size + 1, model_->items().size()); 2702 ASSERT_EQ(initial_size + 1, model_->items().size());
2695 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); 2703 EXPECT_TRUE(launcher_controller_->IsAppPinned("1"));
2696 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); 2704 EXPECT_FALSE(launcher_controller_->IsAppPinned("0"));
2697 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); 2705 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type);
2698 2706
2699 launcher_controller_->UnpinAppWithID("1"); 2707 launcher_controller_->UnpinAppWithID("1");
2700 ASSERT_EQ(initial_size, model_->items().size()); 2708 ASSERT_EQ(initial_size, model_->items().size());
2701 } 2709 }
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_tab_helper.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698