Chromium Code Reviews| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
| 10 #include "chrome/browser/profiles/profile_window.h" | 10 #include "chrome/browser/profiles/profile_window.h" |
| 11 #include "chrome/browser/profiles/profiles_state.h" | 11 #include "chrome/browser/profiles/profiles_state.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_iterator.h" | |
| 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 14 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 16 #include "chrome/grit/chromium_strings.h" | 17 #include "chrome/grit/chromium_strings.h" |
| 17 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
| 18 #include "chrome/test/base/testing_browser_process.h" | 19 #include "chrome/test/base/testing_browser_process.h" |
| 19 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
| 20 #include "components/signin/core/common/profile_management_switches.h" | 21 #include "components/signin/core/common/profile_management_switches.h" |
| 21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/test/browser_test_utils.h" | 23 #include "content/public/test/browser_test_utils.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 24 | 25 |
| 26 namespace { | |
| 27 | |
| 28 int CountBrowsersForProfileByPath(const base::FilePath& profile_path) { | |
|
noms (inactive)
2015/01/29 16:17:06
nit: wrong indentation (don't indent inside the na
Mike Lerman
2015/02/20 16:10:24
Done.
| |
| 29 int count = 0; | |
| 30 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | |
| 31 if (it->profile()->GetOriginalProfile()->GetPath() == profile_path) | |
| 32 count++; | |
| 33 } | |
| 34 return count; | |
| 35 } | |
| 36 | |
| 37 } // namespace | |
| 38 | |
| 25 class UserManagerUIBrowserTest : public InProcessBrowserTest, | 39 class UserManagerUIBrowserTest : public InProcessBrowserTest, |
| 26 public testing::WithParamInterface<bool> { | 40 public testing::WithParamInterface<bool> { |
| 27 public: | 41 public: |
| 28 UserManagerUIBrowserTest() {} | 42 UserManagerUIBrowserTest() {} |
| 29 | 43 |
| 30 protected: | 44 protected: |
| 31 void SetUp() override { | 45 void SetUp() override { |
| 32 InProcessBrowserTest::SetUp(); | 46 InProcessBrowserTest::SetUp(); |
| 33 DCHECK(switches::IsNewAvatarMenu()); | 47 DCHECK(switches::IsNewAvatarMenu()); |
| 34 } | 48 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 bool result = content::ExecuteScript(web_contents, launch_js); | 101 bool result = content::ExecuteScript(web_contents, launch_js); |
| 88 EXPECT_TRUE(result); | 102 EXPECT_TRUE(result); |
| 89 base::RunLoop().RunUntilIdle(); | 103 base::RunLoop().RunUntilIdle(); |
| 90 | 104 |
| 91 content::WebContents* about_chrome_contents = | 105 content::WebContents* about_chrome_contents = |
| 92 browser()->tab_strip_model()->GetActiveWebContents(); | 106 browser()->tab_strip_model()->GetActiveWebContents(); |
| 93 GURL current_URL = about_chrome_contents->GetVisibleURL(); | 107 GURL current_URL = about_chrome_contents->GetVisibleURL(); |
| 94 EXPECT_EQ(GURL(chrome::kChromeUIUberURL), current_URL); | 108 EXPECT_EQ(GURL(chrome::kChromeUIUberURL), current_URL); |
| 95 } | 109 } |
| 96 | 110 |
| 111 IN_PROC_BROWSER_TEST_F(UserManagerUIBrowserTest, LaunchGuest) { | |
| 112 std::string user_manager_url = chrome::kChromeUIUserManagerURL; | |
| 113 | |
| 114 ui_test_utils::NavigateToURL(browser(), GURL(user_manager_url)); | |
| 115 content::WebContents* web_contents = | |
| 116 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 117 EXPECT_EQ(0, CountBrowsersForProfileByPath( | |
| 118 ProfileManager::GetGuestProfilePath())); | |
| 119 | |
| 120 std::string launch_js = | |
| 121 base::StringPrintf("chrome.send('launchGuest')"); | |
| 122 | |
| 123 bool result = content::ExecuteScript(web_contents, launch_js); | |
| 124 EXPECT_TRUE(result); | |
| 125 base::RunLoop().RunUntilIdle(); | |
| 126 | |
| 127 EXPECT_GE(1, CountBrowsersForProfileByPath( | |
| 128 ProfileManager::GetGuestProfilePath())); | |
| 129 } | |
| 130 | |
| 97 // TODO(mlerman): Test that unlocking a locked profile causes the extensions | 131 // TODO(mlerman): Test that unlocking a locked profile causes the extensions |
| 98 // service to become unblocked. | 132 // service to become unblocked. |
| OLD | NEW |