OLD | NEW |
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/app/chrome_command_ids.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/history/history_service_factory.h" | 12 #include "chrome/browser/history/history_service_factory.h" |
13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
14 #include "chrome/browser/search_engines/template_url_service_factory.h" | 14 #include "chrome/browser/search_engines/template_url_service_factory.h" |
15 #include "chrome/browser/signin/signin_manager_factory.h" | 15 #include "chrome/browser/signin/signin_manager_factory.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/browser_finder.h" | 17 #include "chrome/browser/ui/browser_finder.h" |
18 #include "chrome/browser/ui/browser_list.h" | 18 #include "chrome/browser/ui/browser_list.h" |
19 #include "chrome/browser/ui/toolbar/app_menu_model.h" | 19 #include "chrome/browser/ui/toolbar/app_menu_model.h" |
20 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
21 #include "chrome/test/base/search_test_utils.h" | 21 #include "chrome/test/base/search_test_utils.h" |
22 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
23 #include "components/history/core/browser/history_db_task.h" | 23 #include "components/history/core/browser/history_db_task.h" |
24 #include "components/history/core/browser/history_service.h" | 24 #include "components/history/core/browser/history_service.h" |
25 #include "components/search_engines/template_url_service.h" | 25 #include "components/search_engines/template_url_service.h" |
26 #include "components/signin/core/common/profile_management_switches.h" | 26 #include "components/signin/core/common/profile_management_switches.h" |
27 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
28 #include "content/public/test/browser_test_utils.h" | 28 #include "content/public/test/browser_test_utils.h" |
29 #include "content/public/test/test_utils.h" | 29 #include "content/public/test/test_utils.h" |
30 #include "net/test/spawned_test_server/spawned_test_server.h" | 30 #include "net/test/embedded_test_server/embedded_test_server.h" |
31 | 31 |
32 // This test verifies the Desktop implementation of Guest only. | 32 // This test verifies the Desktop implementation of Guest only. |
33 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS) | 33 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS) |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 // Code related to history borrowed from: | 37 // Code related to history borrowed from: |
38 // chrome/browser/history/history_browsertest.cc | 38 // chrome/browser/history/history_browsertest.cc |
39 | 39 |
40 // Note: WaitableEvent is not used for synchronization between the main thread | 40 // Note: WaitableEvent is not used for synchronization between the main thread |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 163 |
164 std::vector<GURL> urls = | 164 std::vector<GURL> urls = |
165 ui_test_utils::HistoryEnumerator(guest_browser->profile()).urls(); | 165 ui_test_utils::HistoryEnumerator(guest_browser->profile()).urls(); |
166 ASSERT_EQ(0U, urls.size()); | 166 ASSERT_EQ(0U, urls.size()); |
167 } | 167 } |
168 | 168 |
169 IN_PROC_BROWSER_TEST_F(ProfileWindowBrowserTest, GuestClearsCookies) { | 169 IN_PROC_BROWSER_TEST_F(ProfileWindowBrowserTest, GuestClearsCookies) { |
170 Browser* guest_browser = OpenGuestBrowser(); | 170 Browser* guest_browser = OpenGuestBrowser(); |
171 Profile* guest_profile = guest_browser->profile(); | 171 Profile* guest_profile = guest_browser->profile(); |
172 | 172 |
173 ASSERT_TRUE(test_server()->Start()); | 173 ASSERT_TRUE(embedded_test_server()->Start()); |
174 GURL url(test_server()->GetURL("set-cookie?cookie1")); | 174 GURL url(embedded_test_server()->GetURL("/set-cookie?cookie1")); |
175 | 175 |
176 // Before navigation there are no cookies for the URL. | 176 // Before navigation there are no cookies for the URL. |
177 std::string cookie = content::GetCookies(guest_profile, url); | 177 std::string cookie = content::GetCookies(guest_profile, url); |
178 ASSERT_EQ("", cookie); | 178 ASSERT_EQ("", cookie); |
179 | 179 |
180 // After navigation there is a cookie for the URL. | 180 // After navigation there is a cookie for the URL. |
181 ui_test_utils::NavigateToURL(guest_browser, url); | 181 ui_test_utils::NavigateToURL(guest_browser, url); |
182 cookie = content::GetCookies(guest_profile, url); | 182 cookie = content::GetCookies(guest_profile, url); |
183 EXPECT_EQ("cookie1", cookie); | 183 EXPECT_EQ("cookie1", cookie); |
184 | 184 |
(...skipping 20 matching lines...) Expand all Loading... |
205 AppMenuModel model_normal_profile(&accelerator_handler, browser()); | 205 AppMenuModel model_normal_profile(&accelerator_handler, browser()); |
206 EXPECT_NE(-1, model_normal_profile.GetIndexOfCommandId(IDC_BOOKMARKS_MENU)); | 206 EXPECT_NE(-1, model_normal_profile.GetIndexOfCommandId(IDC_BOOKMARKS_MENU)); |
207 | 207 |
208 // Guest browser has no bookmark menu. | 208 // Guest browser has no bookmark menu. |
209 Browser* guest_browser = OpenGuestBrowser(); | 209 Browser* guest_browser = OpenGuestBrowser(); |
210 AppMenuModel model_guest_profile(&accelerator_handler, guest_browser); | 210 AppMenuModel model_guest_profile(&accelerator_handler, guest_browser); |
211 EXPECT_EQ(-1, model_guest_profile.GetIndexOfCommandId(IDC_BOOKMARKS_MENU)); | 211 EXPECT_EQ(-1, model_guest_profile.GetIndexOfCommandId(IDC_BOOKMARKS_MENU)); |
212 } | 212 } |
213 | 213 |
214 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS) | 214 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS) |
OLD | NEW |