Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / ui / webui / signin / user_manager_ui_browsertest.cc
blobde7018c8f79374ccf32809e3cfc6fc5524881afe
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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "base/strings/string_util.h"
7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/profiles/profile_window.h"
11 #include "chrome/browser/profiles/profiles_state.h"
12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/url_constants.h"
16 #include "chrome/grit/chromium_strings.h"
17 #include "chrome/test/base/in_process_browser_test.h"
18 #include "chrome/test/base/testing_browser_process.h"
19 #include "chrome/test/base/ui_test_utils.h"
20 #include "components/signin/core/common/profile_management_switches.h"
21 #include "content/public/browser/web_contents.h"
22 #include "content/public/test/browser_test_utils.h"
23 #include "ui/base/l10n/l10n_util.h"
25 class UserManagerUIBrowserTest : public InProcessBrowserTest,
26 public testing::WithParamInterface<bool> {
27 public:
28 UserManagerUIBrowserTest() {}
30 protected:
31 void SetUp() override {
32 InProcessBrowserTest::SetUp();
33 DCHECK(switches::IsNewAvatarMenu());
36 void SetUpCommandLine(base::CommandLine* command_line) override {
37 switches::EnableNewAvatarMenuForTesting(command_line);
41 IN_PROC_BROWSER_TEST_F(UserManagerUIBrowserTest, PageLoads) {
42 ui_test_utils::NavigateToURL(
43 browser(), GURL(chrome::kChromeUIUserManagerURL));
44 content::WebContents* web_contents =
45 browser()->tab_strip_model()->GetActiveWebContents();
47 base::string16 title = web_contents->GetTitle();
48 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), title);
50 // If the page has loaded correctly, then there should be an account picker.
51 int num_account_pickers = -1;
52 ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
53 web_contents,
54 "domAutomationController.send("
55 "document.getElementsByClassName('account-picker').length)",
56 &num_account_pickers));
57 EXPECT_EQ(1, num_account_pickers);
59 int num_pods = -1;
60 ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
61 web_contents,
62 "domAutomationController.send("
63 "parseInt(document.getElementById('pod-row').getAttribute('ncolumns')))",
64 &num_pods));
66 // There should be one user pod for each profile.
67 ProfileManager* profile_manager = g_browser_process->profile_manager();
68 EXPECT_EQ(num_pods, static_cast<int>(profile_manager->GetNumberOfProfiles()));
71 IN_PROC_BROWSER_TEST_F(UserManagerUIBrowserTest, PageRedirectsToAboutChrome) {
72 std::string user_manager_url = chrome::kChromeUIUserManagerURL;
73 user_manager_url += profiles::kUserManagerSelectProfileAboutChrome;
75 ui_test_utils::NavigateToURL(browser(), GURL(user_manager_url));
76 content::WebContents* web_contents =
77 browser()->tab_strip_model()->GetActiveWebContents();
79 // If this is a Windows style path, escape all the slashes.
80 std::string profile_path;
81 base::ReplaceChars(browser()->profile()->GetPath().MaybeAsASCII(),
82 "\\", "\\\\", &profile_path);
84 std::string launch_js =
85 base::StringPrintf("Oobe.launchUser('%s')", profile_path.c_str());
87 bool result = content::ExecuteScript(web_contents, launch_js);
88 EXPECT_TRUE(result);
89 base::RunLoop().RunUntilIdle();
91 content::WebContents* about_chrome_contents =
92 browser()->tab_strip_model()->GetActiveWebContents();
93 GURL current_URL = about_chrome_contents->GetVisibleURL();
94 EXPECT_EQ(GURL(chrome::kChromeUIUberURL), current_URL);
97 // TODO(mlerman): Test that unlocking a locked profile causes the extensions
98 // service to become unblocked.