Chromium Code Reviews| 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 class UserCloudPolicyManagerTest : public LoginPolicyTestBase { | 20 class UserCloudPolicyManagerTest : public LoginPolicyTestBase { |
| 21 protected: | 21 protected: |
| 22 UserCloudPolicyManagerTest() : LoginPolicyTestBase() {} | 22 UserCloudPolicyManagerTest() : LoginPolicyTestBase() { |
| 23 // TODO(nkostylev): Fix this test for webview. http://crbug.com/477402 | |
| 24 set_use_webview(false); | |
|
Dmitry Polukhin
2015/04/22 06:47:07
ditto
Nikita (slow)
2015/04/22 09:01:45
Done.
| |
| 25 } | |
| 23 | 26 |
| 24 scoped_ptr<base::DictionaryValue> GetMandatoryPoliciesValue() const override { | 27 scoped_ptr<base::DictionaryValue> GetMandatoryPoliciesValue() const override { |
| 25 scoped_ptr<base::ListValue> list(new base::ListValue); | 28 scoped_ptr<base::ListValue> list(new base::ListValue); |
| 26 list->AppendString("chrome://policy"); | 29 list->AppendString("chrome://policy"); |
| 27 list->AppendString("chrome://about"); | 30 list->AppendString("chrome://about"); |
| 28 | 31 |
| 29 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 32 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
| 30 dict->Set(key::kRestoreOnStartupURLs, list.Pass()); | 33 dict->Set(key::kRestoreOnStartupURLs, list.Pass()); |
| 31 dict->SetInteger(key::kRestoreOnStartup, | 34 dict->SetInteger(key::kRestoreOnStartup, |
| 32 SessionStartupPref::kPrefValueURLs); | 35 SessionStartupPref::kPrefValueURLs); |
| 33 | 36 |
| 34 return dict; | 37 return dict; |
| 35 } | 38 } |
| 36 | 39 |
| 37 private: | 40 private: |
| 38 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerTest); | 41 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerTest); |
| 39 }; | 42 }; |
| 40 | 43 |
| 41 IN_PROC_BROWSER_TEST_F(UserCloudPolicyManagerTest, StartSession) { | 44 IN_PROC_BROWSER_TEST_P(UserCloudPolicyManagerTest, StartSession) { |
| 42 const char* const kStartupURLs[] = {"chrome://policy", "chrome://about"}; | 45 const char* const kStartupURLs[] = {"chrome://policy", "chrome://about"}; |
| 43 | 46 |
| 44 SkipToLoginScreen(); | 47 SkipToLoginScreen(); |
| 45 LogIn(kAccountId, kAccountPassword); | 48 LogIn(kAccountId, kAccountPassword); |
| 46 | 49 |
| 47 // Check that the startup pages specified in policy were opened. | 50 // Check that the startup pages specified in policy were opened. |
| 48 BrowserList* browser_list = | 51 BrowserList* browser_list = |
| 49 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | 52 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); |
| 50 EXPECT_EQ(1U, browser_list->size()); | 53 EXPECT_EQ(1U, browser_list->size()); |
| 51 Browser* browser = browser_list->get(0); | 54 Browser* browser = browser_list->get(0); |
| 52 ASSERT_TRUE(browser); | 55 ASSERT_TRUE(browser); |
| 53 | 56 |
| 54 TabStripModel* tabs = browser->tab_strip_model(); | 57 TabStripModel* tabs = browser->tab_strip_model(); |
| 55 ASSERT_TRUE(tabs); | 58 ASSERT_TRUE(tabs); |
| 56 const int expected_tab_count = static_cast<int>(arraysize(kStartupURLs)); | 59 const int expected_tab_count = static_cast<int>(arraysize(kStartupURLs)); |
| 57 EXPECT_EQ(expected_tab_count, tabs->count()); | 60 EXPECT_EQ(expected_tab_count, tabs->count()); |
| 58 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) { | 61 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) { |
| 59 EXPECT_EQ(GURL(kStartupURLs[i]), | 62 EXPECT_EQ(GURL(kStartupURLs[i]), |
| 60 tabs->GetWebContentsAt(i)->GetVisibleURL()); | 63 tabs->GetWebContentsAt(i)->GetVisibleURL()); |
| 61 } | 64 } |
| 62 } | 65 } |
| 63 | 66 |
| 67 INSTANTIATE_TEST_CASE_P(UserCloudPolicyManagerTestSuite, | |
| 68 UserCloudPolicyManagerTest, | |
| 69 testing::Bool()); | |
| 70 | |
| 64 } // namespace policy | 71 } // namespace policy |
| OLD | NEW |