Index: chrome/browser/chromeos/policy/user_policy_test_helper.h |
diff --git a/chrome/browser/chromeos/policy/user_policy_test_helper.h b/chrome/browser/chromeos/policy/user_policy_test_helper.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d71b37d67e78dd0df1d40f1966d7c56b49457c43 |
--- /dev/null |
+++ b/chrome/browser/chromeos/policy/user_policy_test_helper.h |
@@ -0,0 +1,66 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_CHROMEOS_POLICY_USER_POLICY_TEST_HELPER_H_ |
+#define CHROME_BROWSER_CHROMEOS_POLICY_USER_POLICY_TEST_HELPER_H_ |
+ |
+#include <string> |
+ |
+#include "base/files/scoped_temp_dir.h" |
+#include "base/macros.h" |
+#include "base/memory/scoped_ptr.h" |
+ |
+class Profile; |
+ |
+namespace base { |
+class CommandLine; |
+class FilePath; |
+class DictionaryValue; |
+} |
+ |
+namespace policy { |
+ |
+class LocalPolicyTestServer; |
+ |
+// This class can be used to apply a user policy to the profile in a |
+// BrowserTest. |
+class UserPolicyTestHelper { |
+ public: |
+ 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.
|
+ virtual ~UserPolicyTestHelper(); |
+ |
+ // Must be called after construction to start the policy test server. |
+ void Init(const base::DictionaryValue& mandatory_policy, |
+ const base::DictionaryValue& recommended_policy); |
+ |
+ // Must be used during BrowserTestBase::SetUpCommandLine to direct Chrome to |
+ // the policy test server. |
+ void UpdateCommandLine(base::CommandLine* command_line) const; |
+ |
+ // Can be optionally used to wait for the initial policy to be applied to the |
+ // 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.
|
+ // obsolete. |
+ void WaitForInitialPolicy(Profile* profile); |
+ |
+ // Update the policy test server with the given policy and refresh the policy |
+ // 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.
|
+ void UpdatePolicy(const base::DictionaryValue& mandatory_policy, |
+ const base::DictionaryValue& recommended_policy, |
+ Profile* profile); |
+ |
+ private: |
+ void WritePolicyFile(const base::DictionaryValue& mandatory, |
+ const base::DictionaryValue& recommended); |
+ base::FilePath PolicyFilePath() const; |
+ |
+ 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.
|
+ base::ScopedTempDir temp_dir_; |
+ scoped_ptr<LocalPolicyTestServer> test_server_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(UserPolicyTestHelper); |
+}; |
+ |
+} // namespace policy |
+ |
+#endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_POLICY_TEST_HELPER_H_ |