Home | History | Annotate | Download | only in signin
      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/grit/chromium_strings.h"
     11 #include "chrome/test/base/in_process_browser_test.h"
     12 #include "chrome/test/base/testing_browser_process.h"
     13 #include "chrome/test/base/ui_test_utils.h"
     14 #include "components/signin/core/common/profile_management_switches.h"
     15 #include "content/public/browser/web_contents.h"
     16 #include "content/public/test/browser_test_utils.h"
     17 #include "ui/base/l10n/l10n_util.h"
     18 
     19 class UserManagerUIBrowserTest : public InProcessBrowserTest,
     20                                  public testing::WithParamInterface<bool> {
     21  public:
     22   UserManagerUIBrowserTest() {}
     23 
     24  protected:
     25   virtual void SetUp() OVERRIDE {
     26     InProcessBrowserTest::SetUp();
     27     DCHECK(switches::IsNewAvatarMenu());
     28   }
     29 
     30   virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
     31     switches::EnableNewAvatarMenuForTesting(command_line);
     32   }
     33 };
     34 
     35 IN_PROC_BROWSER_TEST_F(UserManagerUIBrowserTest, PageLoads) {
     36   ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
     37       browser(), GURL(chrome::kChromeUIUserManagerURL), 1);
     38   content::WebContents* web_contents =
     39       browser()->tab_strip_model()->GetActiveWebContents();
     40 
     41   base::string16 title = web_contents->GetTitle();
     42   EXPECT_EQ(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), title);
     43 
     44   // If the page has loaded correctly, then there should be an account picker.
     45   int num_account_pickers = -1;
     46   ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
     47       web_contents,
     48       "domAutomationController.send("
     49       "document.getElementsByClassName('account-picker').length)",
     50       &num_account_pickers));
     51   EXPECT_EQ(1, num_account_pickers);
     52 
     53   int num_pods = -1;
     54   ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
     55       web_contents,
     56       "domAutomationController.send("
     57       "parseInt(document.getElementById('pod-row').getAttribute('ncolumns')))",
     58       &num_pods));
     59 
     60   // There should be one user pod for each profile.
     61   ProfileManager* profile_manager = g_browser_process->profile_manager();
     62   EXPECT_EQ(num_pods, static_cast<int>(profile_manager->GetNumberOfProfiles()));
     63 }
     64