Chromium Code Reviews| Index: chrome/browser/chromeos/settings/stub_install_attributes.h |
| diff --git a/chrome/browser/chromeos/settings/stub_install_attributes.h b/chrome/browser/chromeos/settings/stub_install_attributes.h |
| index 86a943a7eb38d2d67dc8ca24cdac34dfdbf3af4f..11ced8221bd7799244f37cbf3b5656b7a5f13ee3 100644 |
| --- a/chrome/browser/chromeos/settings/stub_install_attributes.h |
| +++ b/chrome/browser/chromeos/settings/stub_install_attributes.h |
| @@ -13,17 +13,19 @@ |
| namespace chromeos { |
| -// This class allows tests to override specific values for easier testing. |
| -// To make IsEnterpriseDevice() return true, set a non-empty registration |
| -// user. |
| +// This class allows tests to set specific configurations for testing. |
| class StubInstallAttributes : public InstallAttributes { |
| public: |
| StubInstallAttributes(); |
| - void SetDomain(const std::string& domain); |
| - void SetRegistrationUser(const std::string& user); |
| - void SetDeviceId(const std::string& id); |
| - void SetMode(policy::DeviceMode mode); |
| + // Setup as not-yet enrolled. |
| + void Clear(); |
| + |
| + // Setup as consumer device. (Clears existing configuration.) |
| + void SetConsumer(); |
| + |
| + // Setup as enterprise enrolled. (Clears existing configuration.) |
| + void SetEnterprise(const std::string& domain, const std::string& device_id); |
| private: |
| DISALLOW_COPY_AND_ASSIGN(StubInstallAttributes); |
| @@ -32,13 +34,28 @@ class StubInstallAttributes : public InstallAttributes { |
| // Helper class to set install attributes in the scope of a test. |
| class ScopedStubInstallAttributes { |
| public: |
| - ScopedStubInstallAttributes(const std::string& domain, |
| - const std::string& registration_user, |
| - const std::string& device_id, |
| - policy::DeviceMode mode); |
| ~ScopedStubInstallAttributes(); |
| + |
| + private: |
| + friend ScopedStubInstallAttributes ScopedStubInstallAttributesUnset(); |
| + friend ScopedStubInstallAttributes ScopedStubInstallAttributesConsumer(); |
| + friend ScopedStubInstallAttributes ScopedStubInstallAttributesEnterprise( |
| + const std::string& domain, |
| + const std::string& device_id); |
| + ScopedStubInstallAttributes(); |
| }; |
| +// Factory for empty (unset) ScopedStubInstallAttributes. |
| +ScopedStubInstallAttributes ScopedStubInstallAttributesUnset(); |
|
emaxx
2016/10/11 17:26:37
Isn't it more common to make such simple factories
Thiemo Nagel
2016/10/11 18:23:30
Yes, you're right. Looks much better now. :)
|
| + |
| +// Factory for consumer-type ScopedStubInstallAttributes. |
| +ScopedStubInstallAttributes ScopedStubInstallAttributesConsumer(); |
| + |
| +// Factory for enterprise-type ScopedStubInstallAttributes. |
| +ScopedStubInstallAttributes ScopedStubInstallAttributesEnterprise( |
| + const std::string& domain, |
| + const std::string& device_id); |
| + |
| } // namespace chromeos |
| #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_STUB_INSTALL_ATTRIBUTES_H_ |