Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_USER_POLICY_TEST_HELPER_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_POLICY_TEST_HELPER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/files/scoped_temp_dir.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 | |
| 14 class Profile; | |
| 15 | |
| 16 namespace base { | |
| 17 class CommandLine; | |
| 18 class FilePath; | |
| 19 class DictionaryValue; | |
| 20 } | |
| 21 | |
| 22 namespace policy { | |
| 23 | |
| 24 class LocalPolicyTestServer; | |
| 25 | |
| 26 // This class can be used to apply a user policy to the profile in a | |
| 27 // BrowserTest. | |
| 28 class UserPolicyTestHelper { | |
| 29 public: | |
| 30 explicit UserPolicyTestHelper(const std::string& user_email); | |
|
bartfab (slow)
2015/06/15 17:12:27
Nit: "email" is incorrect. The ID may not be an e-
pneubeck (no reviews)
2015/06/16 09:16:21
Done.
| |
| 31 virtual ~UserPolicyTestHelper(); | |
| 32 | |
| 33 // Must be called after construction to start the policy test server. | |
| 34 void Init(const base::DictionaryValue& mandatory_policy, | |
| 35 const base::DictionaryValue& recommended_policy); | |
| 36 | |
| 37 // Must be used during BrowserTestBase::SetUpCommandLine to direct Chrome to | |
| 38 // the policy test server. | |
| 39 void UpdateCommandLine(base::CommandLine* command_line) const; | |
| 40 | |
| 41 // Can be optionally used to wait for the initial policy to be applied to the | |
| 42 // profile. Alternatively, a login can be simulated making this function | |
|
bartfab (slow)
2015/06/15 17:12:27
Nit 1: s/simulated/simulated, /
Nit 2: A login doe
pneubeck (no reviews)
2015/06/16 09:16:21
Done.
| |
| 43 // obsolete. | |
| 44 void WaitForInitialPolicy(Profile* profile); | |
| 45 | |
| 46 // Update the policy test server with the given policy and refresh the policy | |
| 47 // applied to |profile|. | |
|
bartfab (slow)
2015/06/15 17:12:27
Nit: Add a note indicating whether the method wait
pneubeck (no reviews)
2015/06/16 09:16:21
Done.
| |
| 48 void UpdatePolicy(const base::DictionaryValue& mandatory_policy, | |
| 49 const base::DictionaryValue& recommended_policy, | |
| 50 Profile* profile); | |
| 51 | |
| 52 private: | |
| 53 void WritePolicyFile(const base::DictionaryValue& mandatory, | |
| 54 const base::DictionaryValue& recommended); | |
| 55 base::FilePath PolicyFilePath() const; | |
| 56 | |
| 57 const std::string user_email_; | |
|
bartfab (slow)
2015/06/15 17:12:27
Nit: As above, s/user_email_/account_id_/
pneubeck (no reviews)
2015/06/16 09:16:21
Done.
| |
| 58 base::ScopedTempDir temp_dir_; | |
| 59 scoped_ptr<LocalPolicyTestServer> test_server_; | |
| 60 | |
| 61 DISALLOW_COPY_AND_ASSIGN(UserPolicyTestHelper); | |
| 62 }; | |
| 63 | |
| 64 } // namespace policy | |
| 65 | |
| 66 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_POLICY_TEST_HELPER_H_ | |
| OLD | NEW |