Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / chromeos / policy / user_cloud_policy_manager_chromeos_browsertest.cc
blobd529dcec6737b781800976422e4d066346fdbb47
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 <string>
7 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h"
10 #include "chrome/browser/chromeos/policy/login_policy_test_base.h"
11 #include "chrome/browser/prefs/session_startup_pref.h"
12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_list.h"
14 #include "chrome/browser/ui/host_desktop.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "policy/policy_constants.h"
18 namespace policy {
20 // Boolean parameter is used to run this test for webview (true) and for
21 // iframe (false) GAIA sign in.
22 class UserCloudPolicyManagerTest : public LoginPolicyTestBase,
23 public testing::WithParamInterface<bool> {
24 protected:
25 UserCloudPolicyManagerTest() : LoginPolicyTestBase() {
26 set_use_webview(GetParam());
29 void GetMandatoryPoliciesValue(base::DictionaryValue* policy) const override {
30 scoped_ptr<base::ListValue> list(new base::ListValue);
31 list->AppendString("chrome://policy");
32 list->AppendString("chrome://about");
34 policy->Set(key::kRestoreOnStartupURLs, list.Pass());
35 policy->SetInteger(key::kRestoreOnStartup,
36 SessionStartupPref::kPrefValueURLs);
39 private:
40 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerTest);
43 IN_PROC_BROWSER_TEST_P(UserCloudPolicyManagerTest, StartSession) {
44 const char* const kStartupURLs[] = {"chrome://policy", "chrome://about"};
46 SkipToLoginScreen();
47 LogIn(kAccountId, kAccountPassword);
49 // Check that the startup pages specified in policy were opened.
50 BrowserList* browser_list =
51 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
52 EXPECT_EQ(1U, browser_list->size());
53 Browser* browser = browser_list->get(0);
54 ASSERT_TRUE(browser);
56 TabStripModel* tabs = browser->tab_strip_model();
57 ASSERT_TRUE(tabs);
58 const int expected_tab_count = static_cast<int>(arraysize(kStartupURLs));
59 EXPECT_EQ(expected_tab_count, tabs->count());
60 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) {
61 EXPECT_EQ(GURL(kStartupURLs[i]),
62 tabs->GetWebContentsAt(i)->GetVisibleURL());
66 INSTANTIATE_TEST_CASE_P(UserCloudPolicyManagerTestSuite,
67 UserCloudPolicyManagerTest,
68 testing::Bool());
70 } // namespace policy