diff options
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/base/testing_profile.cc | 26 | ||||
-rw-r--r-- | chrome/test/base/testing_profile.h | 8 | ||||
-rw-r--r-- | chrome/test/data/policy/avatar1.jpg | bin | 0 -> 285 bytes | |||
-rw-r--r-- | chrome/test/data/policy/avatar2.jpg | bin | 0 -> 285 bytes | |||
-rw-r--r-- | chrome/test/data/policy/policy_test_cases.json | 4 |
5 files changed, 31 insertions, 7 deletions
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc index 3fa3ef9..73efdfb 100644 --- a/chrome/test/base/testing_profile.cc +++ b/chrome/test/base/testing_profile.cc @@ -41,6 +41,7 @@ #include "chrome/browser/net/proxy_service_factory.h" #include "chrome/browser/notifications/desktop_notification_service.h" #include "chrome/browser/notifications/desktop_notification_service_factory.h" +#include "chrome/browser/policy/policy_service.h" #include "chrome/browser/policy/profile_policy_connector.h" #include "chrome/browser/policy/profile_policy_connector_factory.h" #include "chrome/browser/prefs/browser_prefs.h" @@ -233,6 +234,7 @@ TestingProfile::TestingProfile( scoped_ptr<PrefServiceSyncable> prefs, bool incognito, const std::string& managed_user_id, + scoped_ptr<policy::PolicyService> policy_service, const TestingFactories& factories) : start_time_(Time::Now()), prefs_(prefs.release()), @@ -247,7 +249,8 @@ TestingProfile::TestingProfile( browser_context_dependency_manager_( BrowserContextDependencyManager::GetInstance()), resource_context_(NULL), - delegate_(delegate) { + delegate_(delegate), + policy_service_(policy_service.release()) { // If no profile path was supplied, create one. if (profile_path_.empty()) { @@ -628,22 +631,25 @@ void TestingProfile::CreateTestingPrefService() { } void TestingProfile::CreateProfilePolicyConnector() { - scoped_ptr<policy::PolicyService> service; #if defined(ENABLE_CONFIGURATION_POLICY) schema_registry_service_ = policy::SchemaRegistryServiceFactory::CreateForContext( this, policy::Schema(), NULL); CHECK_EQ(schema_registry_service_.get(), policy::SchemaRegistryServiceFactory::GetForContext(this)); +#endif // defined(ENABLE_CONFIGURATION_POLICY) - std::vector<policy::ConfigurationPolicyProvider*> providers; - service.reset(new policy::PolicyServiceImpl( - providers, policy::PolicyServiceImpl::PreprocessCallback())); +if (!policy_service_) { +#if defined(ENABLE_CONFIGURATION_POLICY) + std::vector<policy::ConfigurationPolicyProvider*> providers; + policy_service_.reset(new policy::PolicyServiceImpl( + providers, policy::PolicyServiceImpl::PreprocessCallback())); #else - service.reset(new policy::PolicyServiceStub()); + policy_service_.reset(new policy::PolicyServiceStub()); #endif + } profile_policy_connector_.reset(new policy::ProfilePolicyConnector()); - profile_policy_connector_->InitForTesting(service.Pass()); + profile_policy_connector_->InitForTesting(policy_service_.Pass()); policy::ProfilePolicyConnectorFactory::GetInstance()->SetServiceForTesting( this, profile_policy_connector_.get()); CHECK_EQ(profile_policy_connector_.get(), @@ -886,6 +892,11 @@ void TestingProfile::Builder::SetManagedUserId( managed_user_id_ = managed_user_id; } +void TestingProfile::Builder::SetPolicyService( + scoped_ptr<policy::PolicyService> policy_service) { + policy_service_ = policy_service.Pass(); +} + void TestingProfile::Builder::AddTestingFactory( BrowserContextKeyedServiceFactory* service_factory, BrowserContextKeyedServiceFactory::FactoryFunction callback) { @@ -903,5 +914,6 @@ scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { pref_service_.Pass(), incognito_, managed_user_id_, + policy_service_.Pass(), testing_factories_)); } diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h index 48b0962..7014623 100644 --- a/chrome/test/base/testing_profile.h +++ b/chrome/test/base/testing_profile.h @@ -31,6 +31,7 @@ class URLRequestContextGetter; } namespace policy { +class PolicyService; class ProfilePolicyConnector; class SchemaRegistryService; } @@ -105,6 +106,9 @@ class TestingProfile : public Profile { // non-empty string, the profile is managed. void SetManagedUserId(const std::string& managed_user_id); + // Sets the PolicyService to be used by this profile. + void SetPolicyService(scoped_ptr<policy::PolicyService> policy_service); + // Creates the TestingProfile using previously-set settings. scoped_ptr<TestingProfile> Build(); @@ -119,6 +123,7 @@ class TestingProfile : public Profile { Delegate* delegate_; bool incognito_; std::string managed_user_id_; + scoped_ptr<policy::PolicyService> policy_service_; TestingFactories testing_factories_; DISALLOW_COPY_AND_ASSIGN(Builder); @@ -145,6 +150,7 @@ class TestingProfile : public Profile { scoped_ptr<PrefServiceSyncable> prefs, bool incognito, const std::string& managed_user_id, + scoped_ptr<policy::PolicyService> policy_service, const TestingFactories& factories); virtual ~TestingProfile(); @@ -402,6 +408,8 @@ class TestingProfile : public Profile { Delegate* delegate_; std::string profile_name_; + + scoped_ptr<policy::PolicyService> policy_service_; }; #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_ diff --git a/chrome/test/data/policy/avatar1.jpg b/chrome/test/data/policy/avatar1.jpg Binary files differnew file mode 100644 index 0000000..655dea9 --- /dev/null +++ b/chrome/test/data/policy/avatar1.jpg diff --git a/chrome/test/data/policy/avatar2.jpg b/chrome/test/data/policy/avatar2.jpg Binary files differnew file mode 100644 index 0000000..b6f56cf --- /dev/null +++ b/chrome/test/data/policy/avatar2.jpg diff --git a/chrome/test/data/policy/policy_test_cases.json b/chrome/test/data/policy/policy_test_cases.json index b46e9dd..03c335a 100644 --- a/chrome/test/data/policy/policy_test_cases.json +++ b/chrome/test/data/policy/policy_test_cases.json @@ -1548,6 +1548,10 @@ "ForceEphemeralProfiles": { }, + "UserAvatarImage": { + "os": ["chromeos"] + }, + "----- Chrome OS policies ------------------------------------------------": {}, "ChromeOsLockOnIdleSuspend": { |