OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/chromeos/policy/login_policy_test_base.h" | 10 #include "chrome/browser/chromeos/policy/login_policy_test_base.h" |
11 #include "chrome/browser/prefs/session_startup_pref.h" | 11 #include "chrome/browser/prefs/session_startup_pref.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_list.h" |
14 #include "chrome/browser/ui/host_desktop.h" | 14 #include "chrome/browser/ui/host_desktop.h" |
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
16 #include "policy/policy_constants.h" | 16 #include "policy/policy_constants.h" |
17 | 17 |
18 namespace policy { | 18 namespace policy { |
19 | 19 |
20 // Boolean parameter is used to run this test for webview (true) and for | 20 class UserCloudPolicyManagerTest : public LoginPolicyTestBase { |
21 // iframe (false) GAIA sign in. | |
22 class UserCloudPolicyManagerTest : public LoginPolicyTestBase, | |
23 public testing::WithParamInterface<bool> { | |
24 protected: | 21 protected: |
25 UserCloudPolicyManagerTest() : LoginPolicyTestBase() { | 22 UserCloudPolicyManagerTest() : LoginPolicyTestBase() {} |
26 set_use_webview(GetParam()); | |
27 } | |
28 | 23 |
29 scoped_ptr<base::DictionaryValue> GetMandatoryPoliciesValue() const override { | 24 scoped_ptr<base::DictionaryValue> GetMandatoryPoliciesValue() const override { |
30 scoped_ptr<base::ListValue> list(new base::ListValue); | 25 scoped_ptr<base::ListValue> list(new base::ListValue); |
31 list->AppendString("chrome://policy"); | 26 list->AppendString("chrome://policy"); |
32 list->AppendString("chrome://about"); | 27 list->AppendString("chrome://about"); |
33 | 28 |
34 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 29 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
35 dict->Set(key::kRestoreOnStartupURLs, list.Pass()); | 30 dict->Set(key::kRestoreOnStartupURLs, list.Pass()); |
36 dict->SetInteger(key::kRestoreOnStartup, | 31 dict->SetInteger(key::kRestoreOnStartup, |
37 SessionStartupPref::kPrefValueURLs); | 32 SessionStartupPref::kPrefValueURLs); |
38 | 33 |
39 return dict; | 34 return dict; |
40 } | 35 } |
41 | 36 |
42 private: | 37 private: |
43 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerTest); | 38 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerTest); |
44 }; | 39 }; |
45 | 40 |
46 IN_PROC_BROWSER_TEST_P(UserCloudPolicyManagerTest, StartSession) { | 41 IN_PROC_BROWSER_TEST_F(UserCloudPolicyManagerTest, StartSession) { |
47 const char* const kStartupURLs[] = {"chrome://policy", "chrome://about"}; | 42 const char* const kStartupURLs[] = {"chrome://policy", "chrome://about"}; |
48 | 43 |
49 SkipToLoginScreen(); | 44 SkipToLoginScreen(); |
50 LogIn(kAccountId, kAccountPassword); | 45 LogIn(kAccountId, kAccountPassword); |
51 | 46 |
52 // Check that the startup pages specified in policy were opened. | 47 // Check that the startup pages specified in policy were opened. |
53 BrowserList* browser_list = | 48 BrowserList* browser_list = |
54 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | 49 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); |
55 EXPECT_EQ(1U, browser_list->size()); | 50 EXPECT_EQ(1U, browser_list->size()); |
56 Browser* browser = browser_list->get(0); | 51 Browser* browser = browser_list->get(0); |
57 ASSERT_TRUE(browser); | 52 ASSERT_TRUE(browser); |
58 | 53 |
59 TabStripModel* tabs = browser->tab_strip_model(); | 54 TabStripModel* tabs = browser->tab_strip_model(); |
60 ASSERT_TRUE(tabs); | 55 ASSERT_TRUE(tabs); |
61 const int expected_tab_count = static_cast<int>(arraysize(kStartupURLs)); | 56 const int expected_tab_count = static_cast<int>(arraysize(kStartupURLs)); |
62 EXPECT_EQ(expected_tab_count, tabs->count()); | 57 EXPECT_EQ(expected_tab_count, tabs->count()); |
63 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) { | 58 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) { |
64 EXPECT_EQ(GURL(kStartupURLs[i]), | 59 EXPECT_EQ(GURL(kStartupURLs[i]), |
65 tabs->GetWebContentsAt(i)->GetVisibleURL()); | 60 tabs->GetWebContentsAt(i)->GetVisibleURL()); |
66 } | 61 } |
67 } | 62 } |
68 | 63 |
69 INSTANTIATE_TEST_CASE_P(UserCloudPolicyManagerTestSuite, | |
70 UserCloudPolicyManagerTest, | |
71 testing::Bool()); | |
72 | |
73 } // namespace policy | 64 } // namespace policy |
OLD | NEW |