| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/chromeos/policy/login_policy_test_base.h" | 10 #include "chrome/browser/chromeos/policy/login_policy_test_base.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 | 30 |
| 31 // Verifies that the |kRestoreOnStartup| and |kRestoreOnStartupURLs| policies | 31 // Verifies that the |kRestoreOnStartup| and |kRestoreOnStartupURLs| policies |
| 32 // are honored on Chrome OS. | 32 // are honored on Chrome OS. |
| 33 class RestoreOnStartupTestChromeOS : public LoginPolicyTestBase { | 33 class RestoreOnStartupTestChromeOS : public LoginPolicyTestBase { |
| 34 public: | 34 public: |
| 35 RestoreOnStartupTestChromeOS(); | 35 RestoreOnStartupTestChromeOS(); |
| 36 | 36 |
| 37 // LoginPolicyTestBase: | 37 // LoginPolicyTestBase: |
| 38 void SetUpCommandLine(base::CommandLine* command_line) override; | 38 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 39 scoped_ptr<base::DictionaryValue> GetMandatoryPoliciesValue() const override; | 39 void GetMandatoryPoliciesValue(base::DictionaryValue* policy) const override; |
| 40 | 40 |
| 41 void LogInAndVerifyStartUpURLs(); | 41 void LogInAndVerifyStartUpURLs(); |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 DISALLOW_COPY_AND_ASSIGN(RestoreOnStartupTestChromeOS); | 44 DISALLOW_COPY_AND_ASSIGN(RestoreOnStartupTestChromeOS); |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 RestoreOnStartupTestChromeOS::RestoreOnStartupTestChromeOS() { | 47 RestoreOnStartupTestChromeOS::RestoreOnStartupTestChromeOS() { |
| 48 } | 48 } |
| 49 | 49 |
| 50 void RestoreOnStartupTestChromeOS::SetUpCommandLine( | 50 void RestoreOnStartupTestChromeOS::SetUpCommandLine( |
| 51 base::CommandLine* command_line) { | 51 base::CommandLine* command_line) { |
| 52 LoginPolicyTestBase::SetUpCommandLine(command_line); | 52 LoginPolicyTestBase::SetUpCommandLine(command_line); |
| 53 command_line->AppendSwitch(switches::kDisableChildAccountDetection); | 53 command_line->AppendSwitch(switches::kDisableChildAccountDetection); |
| 54 } | 54 } |
| 55 | 55 |
| 56 scoped_ptr<base::DictionaryValue> | 56 void RestoreOnStartupTestChromeOS::GetMandatoryPoliciesValue( |
| 57 RestoreOnStartupTestChromeOS::GetMandatoryPoliciesValue() const { | 57 base::DictionaryValue* policy) const { |
| 58 scoped_ptr<base::DictionaryValue> policy(new base::DictionaryValue); | |
| 59 policy->SetInteger(key::kRestoreOnStartup, | 58 policy->SetInteger(key::kRestoreOnStartup, |
| 60 SessionStartupPref::kPrefValueURLs); | 59 SessionStartupPref::kPrefValueURLs); |
| 61 scoped_ptr<base::ListValue> urls(new base::ListValue); | 60 scoped_ptr<base::ListValue> urls(new base::ListValue); |
| 62 urls->AppendString(kStartUpURL1); | 61 urls->AppendString(kStartUpURL1); |
| 63 urls->AppendString(kStartUpURL2); | 62 urls->AppendString(kStartUpURL2); |
| 64 policy->Set(key::kRestoreOnStartupURLs, urls.Pass()); | 63 policy->Set(key::kRestoreOnStartupURLs, urls.Pass()); |
| 65 return policy; | |
| 66 } | 64 } |
| 67 | 65 |
| 68 void RestoreOnStartupTestChromeOS::LogInAndVerifyStartUpURLs() { | 66 void RestoreOnStartupTestChromeOS::LogInAndVerifyStartUpURLs() { |
| 69 LogIn(kAccountId, kAccountPassword); | 67 LogIn(kAccountId, kAccountPassword); |
| 70 | 68 |
| 71 const BrowserList* const browser_list = | 69 const BrowserList* const browser_list = |
| 72 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | 70 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); |
| 73 ASSERT_EQ(1U, browser_list->size()); | 71 ASSERT_EQ(1U, browser_list->size()); |
| 74 const Browser* const browser = browser_list->get(0); | 72 const Browser* const browser = browser_list->get(0); |
| 75 ASSERT_TRUE(browser); | 73 ASSERT_TRUE(browser); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 88 | 86 |
| 89 // Verify that the policies are honored on an existing user's login. | 87 // Verify that the policies are honored on an existing user's login. |
| 90 IN_PROC_BROWSER_TEST_F(RestoreOnStartupTestChromeOS, LogInAndVerify) { | 88 IN_PROC_BROWSER_TEST_F(RestoreOnStartupTestChromeOS, LogInAndVerify) { |
| 91 content::WindowedNotificationObserver( | 89 content::WindowedNotificationObserver( |
| 92 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 90 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
| 93 content::NotificationService::AllSources()).Wait(); | 91 content::NotificationService::AllSources()).Wait(); |
| 94 LogInAndVerifyStartUpURLs(); | 92 LogInAndVerifyStartUpURLs(); |
| 95 } | 93 } |
| 96 | 94 |
| 97 } // namespace policy | 95 } // namespace policy |
| OLD | NEW |