| 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 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_POLICY_TEST_BASE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_POLICY_TEST_BASE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_POLICY_TEST_BASE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_POLICY_TEST_BASE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" | 13 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class FilePath; | 16 class FilePath; |
| 17 class DictionaryValue; | 17 class DictionaryValue; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace policy { | 20 namespace policy { |
| 21 | 21 |
| 22 class LocalPolicyTestServer; | 22 class LocalPolicyTestServer; |
| 23 | 23 |
| 24 class PolicyTestHelper { |
| 25 public: |
| 26 PolicyTestHelper(const std::string& user_email, |
| 27 const base::DictionaryValue& mandatory, |
| 28 const base::DictionaryValue& recommended); |
| 29 virtual ~PolicyTestHelper(); |
| 30 |
| 31 void UpdateCommandLine(base::CommandLine* command_line); |
| 32 void WaitForInitialPolicy(Profile* profile); |
| 33 void UpdatePolicy(Profile* profile, |
| 34 const base::DictionaryValue& mandatory, |
| 35 const base::DictionaryValue& recommended); |
| 36 |
| 37 static const char kAccountId[]; |
| 38 |
| 39 private: |
| 40 void SetServerPolicy(const base::DictionaryValue& mandatory, |
| 41 const base::DictionaryValue& recommended); |
| 42 base::FilePath PolicyFilePath() const; |
| 43 |
| 44 const std::string user_email_; |
| 45 base::ScopedTempDir temp_dir_; |
| 46 scoped_ptr<LocalPolicyTestServer> test_server_; |
| 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(PolicyTestHelper); |
| 49 }; |
| 50 |
| 51 |
| 24 // This class can be used to implement tests which need policy to be set prior | 52 // This class can be used to implement tests which need policy to be set prior |
| 25 // to login. | 53 // to login. |
| 26 class LoginPolicyTestBase : public chromeos::OobeBaseTest { | 54 class LoginPolicyTestBase : public chromeos::OobeBaseTest { |
| 27 protected: | 55 protected: |
| 28 LoginPolicyTestBase(); | 56 LoginPolicyTestBase(); |
| 29 ~LoginPolicyTestBase() override; | 57 ~LoginPolicyTestBase() override; |
| 30 | 58 |
| 31 // chromeos::OobeBaseTest:: | 59 // chromeos::OobeBaseTest:: |
| 32 void SetUp() override; | 60 void SetUp() override; |
| 33 void SetUpCommandLine(base::CommandLine* command_line) override; | 61 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 34 void SetUpOnMainThread() override; | 62 void SetUpOnMainThread() override; |
| 35 | 63 |
| 36 virtual scoped_ptr<base::DictionaryValue> GetMandatoryPoliciesValue() const; | 64 virtual scoped_ptr<base::DictionaryValue> GetMandatoryPoliciesValue() const; |
| 37 virtual scoped_ptr<base::DictionaryValue> GetRecommendedPoliciesValue() const; | 65 virtual scoped_ptr<base::DictionaryValue> GetRecommendedPoliciesValue() const; |
| 38 | 66 |
| 39 void SkipToLoginScreen(); | 67 void SkipToLoginScreen(); |
| 40 void LogIn(const std::string& user_id, const std::string& password); | 68 void LogIn(const std::string& user_id, const std::string& password); |
| 41 | 69 |
| 42 static const char kAccountPassword[]; | 70 static const char kAccountPassword[]; |
| 43 static const char kAccountId[]; | 71 static const char kAccountId[]; |
| 44 | 72 |
| 45 private: | 73 private: |
| 46 void SetUpGaiaServerWithAccessTokens(); | 74 void SetUpGaiaServerWithAccessTokens(); |
| 47 void SetMergeSessionParams(const std::string& email); | 75 void SetMergeSessionParams(); |
| 48 void SetServerPolicy(); | |
| 49 base::FilePath PolicyFilePath() const; | |
| 50 | 76 |
| 51 scoped_ptr<LocalPolicyTestServer> test_server_; | 77 scoped_ptr<PolicyTestHelper> policy_helper_; |
| 52 base::ScopedTempDir temp_dir_; | |
| 53 | 78 |
| 54 DISALLOW_COPY_AND_ASSIGN(LoginPolicyTestBase); | 79 DISALLOW_COPY_AND_ASSIGN(LoginPolicyTestBase); |
| 55 }; | 80 }; |
| 56 | 81 |
| 57 } // namespace policy | 82 } // namespace policy |
| 58 | 83 |
| 59 #endif // CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_POLICY_TEST_BASE_H_ | 84 #endif // CHROME_BROWSER_CHROMEOS_POLICY_LOGIN_POLICY_TEST_BASE_H_ |
| OLD | NEW |