Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / signin / user_manager_ui_browsertest.cc
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.
4 #include "base/command_line.h"
5 #include "chrome/browser/profiles/profile_manager.h"
6 #include "chrome/browser/ui/browser.h"
7 #include "chrome/browser/ui/tabs/tab_strip_model.h"
8 #include "chrome/common/chrome_switches.h"
9 #include "chrome/common/url_constants.h"
10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "chrome/test/base/testing_browser_process.h"
12 #include "chrome/test/base/ui_test_utils.h"
13 #include "content/public/browser/web_contents.h"
14 #include "content/public/test/browser_test_utils.h"
15 #include "grit/generated_resources.h"
16 #include "ui/base/l10n/l10n_util.h"
17
18 namespace {
19 const GURL& url = GURL(chrome::kChromeUIUserManagerURL);
20 }  // namespace
21
22 class UserManagerUIBrowserTest : public InProcessBrowserTest,
23                                  public testing::WithParamInterface<bool> {
24  public:
25   UserManagerUIBrowserTest() {}
26
27  protected:
28    virtual void SetUp() OVERRIDE {
29     InProcessBrowserTest::SetUp();
30     DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(
31         switches::kNewProfileManagement));
32   }
33
34   virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
35     command_line->AppendSwitch(switches::kNewProfileManagement);
36   }
37 };
38
39 IN_PROC_BROWSER_TEST_F(UserManagerUIBrowserTest, PageLoads) {
40   ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 1);
41   content::WebContents* web_contents =
42       browser()->tab_strip_model()->GetActiveWebContents();
43
44   base::string16 title = web_contents->GetTitle();
45   EXPECT_EQ(l10n_util::GetStringUTF16(IDS_USER_MANAGER_SCREEN_TITLE), title);
46
47   // If the page has loaded correctly, then there should be an account picker.
48   int num_account_pickers = -1;
49   ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
50       web_contents,
51       "domAutomationController.send("
52       "document.getElementsByClassName('account-picker').length)",
53       &num_account_pickers));
54   EXPECT_EQ(1, num_account_pickers);
55
56   int num_pods = -1;
57   ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
58       web_contents,
59       "domAutomationController.send("
60       "parseInt(document.getElementById('pod-row').getAttribute('ncolumns')))",
61       &num_pods));
62
63   // There should be one user pod for each profile.
64   ProfileManager* profile_manager = g_browser_process->profile_manager();
65   EXPECT_EQ(num_pods, static_cast<int>(profile_manager->GetNumberOfProfiles()));
66 }