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

Side by Side Diff: chrome/browser/profiles/profile_window_browsertest.cc

Issue 953723003: Guest mode doesn't show the Bookmarks item in Wrench Menu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Browser test. Created 5 years, 9 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 | « no previous file | chrome/browser/ui/toolbar/wrench_menu_model.cc » ('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 (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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/profiles/profile_window.h" 5 #include "chrome/browser/profiles/profile_window.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/history/history_service.h" 12 #include "chrome/browser/history/history_service.h"
12 #include "chrome/browser/history/history_service_factory.h" 13 #include "chrome/browser/history/history_service_factory.h"
13 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/search_engines/template_url_service_factory.h" 15 #include "chrome/browser/search_engines/template_url_service_factory.h"
15 #include "chrome/browser/signin/signin_manager_factory.h" 16 #include "chrome/browser/signin/signin_manager_factory.h"
16 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_finder.h" 18 #include "chrome/browser/ui/browser_finder.h"
18 #include "chrome/browser/ui/browser_list.h" 19 #include "chrome/browser/ui/browser_list.h"
20 #include "chrome/browser/ui/toolbar/wrench_menu_model.h"
19 #include "chrome/test/base/in_process_browser_test.h" 21 #include "chrome/test/base/in_process_browser_test.h"
20 #include "chrome/test/base/ui_test_utils.h" 22 #include "chrome/test/base/ui_test_utils.h"
21 #include "components/history/core/browser/history_db_task.h" 23 #include "components/history/core/browser/history_db_task.h"
22 #include "components/search_engines/template_url_service.h" 24 #include "components/search_engines/template_url_service.h"
23 #include "components/signin/core/common/profile_management_switches.h" 25 #include "components/signin/core/common/profile_management_switches.h"
24 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
25 #include "content/public/test/browser_test_utils.h" 27 #include "content/public/test/browser_test_utils.h"
26 #include "content/public/test/test_utils.h" 28 #include "content/public/test/test_utils.h"
27 #include "net/test/spawned_test_server/spawned_test_server.h" 29 #include "net/test/spawned_test_server/spawned_test_server.h"
28 30
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 63
62 void WaitForHistoryBackendToRun(Profile* profile) { 64 void WaitForHistoryBackendToRun(Profile* profile) {
63 base::CancelableTaskTracker task_tracker; 65 base::CancelableTaskTracker task_tracker;
64 scoped_ptr<history::HistoryDBTask> task(new WaitForHistoryTask()); 66 scoped_ptr<history::HistoryDBTask> task(new WaitForHistoryTask());
65 HistoryService* history = HistoryServiceFactory::GetForProfile( 67 HistoryService* history = HistoryServiceFactory::GetForProfile(
66 profile, ServiceAccessType::EXPLICIT_ACCESS); 68 profile, ServiceAccessType::EXPLICIT_ACCESS);
67 history->HistoryService::ScheduleDBTask(task.Pass(), &task_tracker); 69 history->HistoryService::ScheduleDBTask(task.Pass(), &task_tracker);
68 content::RunMessageLoop(); 70 content::RunMessageLoop();
69 } 71 }
70 72
73 class EmptyAcceleratorHandler : public ui::AcceleratorProvider {
74 public:
75 // Don't handle accelerators.
76 bool GetAcceleratorForCommandId(int command_id,
77 ui::Accelerator* accelerator) override {
78 return false;
79 }
80 };
81
71 } // namespace 82 } // namespace
72 83
73 class ProfileWindowBrowserTest : public InProcessBrowserTest { 84 class ProfileWindowBrowserTest : public InProcessBrowserTest {
74 public: 85 public:
75 ProfileWindowBrowserTest() {} 86 ProfileWindowBrowserTest() {}
76 ~ProfileWindowBrowserTest() override {} 87 ~ProfileWindowBrowserTest() override {}
77 88
78 void SetUpCommandLine(base::CommandLine* command_line) override { 89 void SetUpCommandLine(base::CommandLine* command_line) override {
79 InProcessBrowserTest::SetUpCommandLine(command_line); 90 InProcessBrowserTest::SetUpCommandLine(command_line);
80 switches::EnableNewAvatarMenuForTesting( 91 switches::EnableNewAvatarMenuForTesting(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 IN_PROC_BROWSER_TEST_F(ProfileWindowBrowserTest, GuestCannotSignin) { 192 IN_PROC_BROWSER_TEST_F(ProfileWindowBrowserTest, GuestCannotSignin) {
182 Browser* guest_browser = OpenGuestBrowser(); 193 Browser* guest_browser = OpenGuestBrowser();
183 194
184 SigninManager* signin_manager = SigninManagerFactory::GetForProfile( 195 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(
185 guest_browser->profile()); 196 guest_browser->profile());
186 197
187 // Guest profiles can't sign in without a SigninManager. 198 // Guest profiles can't sign in without a SigninManager.
188 ASSERT_FALSE(signin_manager); 199 ASSERT_FALSE(signin_manager);
189 } 200 }
190 201
202 IN_PROC_BROWSER_TEST_F(ProfileWindowBrowserTest, GuestWrenchLacksBookmarks) {
203 EmptyAcceleratorHandler accelerator_handler;
204 // Verify the normal browser has a bookmark menu.
205 WrenchMenuModel model_normal_profile(&accelerator_handler, browser());
206 EXPECT_NE(-1, model_normal_profile.GetIndexOfCommandId(IDC_BOOKMARKS_MENU));
207
208 // Guest browser has no bookmark menu.
209 Browser* guest_browser = OpenGuestBrowser();
210 WrenchMenuModel model_guest_profile(&accelerator_handler, guest_browser);
211 EXPECT_EQ(-1, model_guest_profile.GetIndexOfCommandId(IDC_BOOKMARKS_MENU));
212 }
213
191 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS) 214 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/toolbar/wrench_menu_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698