Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / ui / webui / options / chromeos / shared_options_browsertest.cc
blob48cb76007f437c115fa83f18728e0c735020d794
1 // Copyright 2014 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/basictypes.h"
6 #include "base/compiler_specific.h"
7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/chromeos/login/login_manager_test.h"
9 #include "chrome/browser/chromeos/login/startup_utils.h"
10 #include "chrome/browser/chromeos/login/user_adding_screen.h"
11 #include "chrome/browser/chromeos/login/user_manager.h"
12 #include "chrome/browser/chromeos/settings/cros_settings.h"
13 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/pref_names.h"
18 #include "chrome/test/base/ui_test_utils.h"
19 #include "chromeos/settings/cros_settings_names.h"
20 #include "content/public/browser/web_contents.h"
21 #include "content/public/test/browser_test_utils.h"
22 #include "content/public/test/test_utils.h"
24 namespace chromeos {
26 namespace {
28 const char* kTestUsers[] = { "test-user1@gmail.com", "test-user2@gmail.com" };
30 } // namespace
32 class SharedOptionsTest : public LoginManagerTest {
33 public:
34 SharedOptionsTest()
35 : LoginManagerTest(false),
36 device_settings_provider_(NULL) {
37 stub_settings_provider_.Set(kDeviceOwner, base::StringValue(kTestUsers[0]));
40 virtual ~SharedOptionsTest() {
43 virtual void SetUpOnMainThread() OVERRIDE {
44 LoginManagerTest::SetUpOnMainThread();
45 CrosSettings* settings = CrosSettings::Get();
46 device_settings_provider_ = settings->GetProvider(kDeviceOwner);
47 settings->RemoveSettingsProvider(device_settings_provider_);
48 settings->AddSettingsProvider(&stub_settings_provider_);
51 virtual void CleanUpOnMainThread() OVERRIDE {
52 CrosSettings* settings = CrosSettings::Get();
53 settings->RemoveSettingsProvider(&stub_settings_provider_);
54 settings->AddSettingsProvider(device_settings_provider_);
55 LoginManagerTest::CleanUpOnMainThread();
58 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
59 LoginManagerTest::SetUpCommandLine(command_line);
60 command_line->AppendSwitch(::switches::kMultiProfiles);
63 protected:
64 void CheckOptionsUI(const User* user, bool is_primary) {
65 Profile* profile = UserManager::Get()->GetProfileByUser(user);
66 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
67 user->email());
69 ui_test_utils::BrowserAddedObserver observer;
70 Browser* browser = CreateBrowser(profile);
71 observer.WaitForSingleNewBrowser();
73 ui_test_utils::NavigateToURL(browser,
74 GURL("chrome://settings-frame"));
75 content::WebContents* contents =
76 browser->tab_strip_model()->GetActiveWebContents();
78 bool banner_visible;
79 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
80 contents,
81 "var e = document.getElementById('secondary-user-banner');"
82 "var visible = e.offsetWidth > 0 && e.offsetHeight > 0;"
83 "window.domAutomationController.send(visible);",
84 &banner_visible));
85 EXPECT_EQ(is_primary, !banner_visible);
88 StubCrosSettingsProvider stub_settings_provider_;
89 CrosSettingsProvider* device_settings_provider_;
91 private:
92 DISALLOW_COPY_AND_ASSIGN(SharedOptionsTest);
95 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, PRE_SharedOptions) {
96 RegisterUser(kTestUsers[0]);
97 RegisterUser(kTestUsers[1]);
98 StartupUtils::MarkOobeCompleted();
101 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, SharedOptions) {
102 LoginUser(kTestUsers[0]);
103 UserAddingScreen::Get()->Start();
104 content::RunAllPendingInMessageLoop();
105 AddUser(kTestUsers[1]);
107 UserManager* manager = UserManager::Get();
108 ASSERT_EQ(2u, manager->GetLoggedInUsers().size());
110 CheckOptionsUI(manager->FindUser(kTestUsers[0]), true /* is_primary */);
111 CheckOptionsUI(manager->FindUser(kTestUsers[1]), false /* is_primary */);
114 } // namespace chromeos