Index: chrome/browser/chromeos/login/managed/managed_user_test_base.h |
diff --git a/chrome/browser/chromeos/login/managed/managed_user_test_base.h b/chrome/browser/chromeos/login/managed/managed_user_test_base.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1aa80d395a270304f264a2fda90522cf56c6895e |
--- /dev/null |
+++ b/chrome/browser/chromeos/login/managed/managed_user_test_base.h |
@@ -0,0 +1,138 @@ |
+// Copyright 2013 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_LOGIN_MANAGED_MANAGED_USER_TEST_BASE_H_ |
+#define CHROME_BROWSER_CHROMEOS_LOGIN_MANAGED_MANAGED_USER_TEST_BASE_H_ |
+ |
+#include <string> |
+ |
+#include "base/compiler_specific.h" |
+#include "base/run_loop.h" |
+#include "base/strings/utf_string_conversions.h" |
Nikita (slow)
2014/04/23 09:50:17
Please cleanup includes. It looks like not all of
Denis Kuznetsov (DE-MUC)
2014/04/24 17:44:09
Done.
|
+#include "base/threading/sequenced_worker_pool.h" |
+#include "chrome/browser/chrome_notification_types.h" |
+#include "chrome/browser/chromeos/login/login_display_host_impl.h" |
+#include "chrome/browser/chromeos/login/login_manager_test.h" |
+#include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h" |
+#include "chrome/browser/chromeos/login/startup_utils.h" |
+#include "chrome/browser/chromeos/login/supervised_user_manager.h" |
+#include "chrome/browser/chromeos/login/webui_login_view.h" |
+#include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" |
+#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" |
+#include "chrome/browser/managed_mode/managed_user_constants.h" |
+#include "chrome/browser/managed_mode/managed_user_registration_utility.h" |
+#include "chrome/browser/managed_mode/managed_user_registration_utility_stub.h" |
+#include "chrome/browser/managed_mode/managed_user_shared_settings_service.h" |
+#include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h" |
+#include "chrome/browser/managed_mode/managed_user_sync_service.h" |
+#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h" |
+#include "chromeos/cryptohome/mock_async_method_caller.h" |
+#include "chromeos/cryptohome/mock_homedir_methods.h" |
+#include "content/public/browser/notification_service.h" |
+#include "content/public/test/browser_test_utils.h" |
+#include "content/public/test/test_utils.h" |
+#include "sync/api/attachments/attachment_service_proxy_for_test.h" |
+#include "sync/api/fake_sync_change_processor.h" |
+#include "sync/api/sync_change.h" |
+#include "sync/api/sync_error_factory_mock.h" |
+#include "sync/protocol/sync.pb.h" |
+ |
+namespace chromeos { |
+ |
+namespace testing { |
+ |
+const char kStubEthernetServicePath[] = "eth0"; |
Nikita (slow)
2014/04/23 09:50:17
nit: Move to .cc
|
+ |
+const char kTestManager[] = "test-manager@gmail.com"; |
+const char kTestOtherUser[] = "test-user@gmail.com"; |
+ |
+const char kTestManagerPassword[] = "password"; |
+const char kTestSupervisedUserDisplayName[] = "John Doe"; |
+const char kTestSupervisedUserPassword[] = "simplepassword"; |
+ |
+class ManagedUsersSyncTestAdapter { |
+ public: |
+ explicit ManagedUsersSyncTestAdapter(Profile* profile); |
+ |
+ bool HasChanges() { return !processor_->changes().empty(); } |
+ |
+ scoped_ptr< ::sync_pb::ManagedUserSpecifics> GetFirstChange(); |
+ |
+ void AddChange(const ::sync_pb::ManagedUserSpecifics& proto); |
+ |
+ syncer::FakeSyncChangeProcessor* processor_; |
+ ManagedUserSyncService* service_; |
+ int next_sync_data_id_; |
+}; |
+ |
+class ManagedUsersSharedSettingsSyncTestAdapter { |
+ public: |
+ explicit ManagedUsersSharedSettingsSyncTestAdapter(Profile* profile); |
+ |
+ bool HasChanges() { return !processor_->changes().empty(); } |
+ |
+ scoped_ptr< ::sync_pb::ManagedUserSharedSettingSpecifics> GetFirstChange(); |
+ |
+ void AddChange(const ::sync_pb::ManagedUserSharedSettingSpecifics& proto); |
+ |
+ void AddChange(const std::string& mu_id, |
+ const std::string& key, |
+ const base::Value& value, |
+ bool acknowledged); |
+ |
+ syncer::FakeSyncChangeProcessor* processor_; |
+ ManagedUserSharedSettingsService* service_; |
+ int next_sync_data_id_; |
+}; |
+ |
+class ManagedUserTestBase : public chromeos::LoginManagerTest { |
+ public: |
+ ManagedUserTestBase(); |
+ virtual ~ManagedUserTestBase(); |
+ |
+ virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; |
+ virtual void CleanUpOnMainThread() OVERRIDE; |
+ |
+ protected: |
+ virtual void TearDown() OVERRIDE; |
+ |
+ virtual void TearDownInProcessBrowserTestFixture() OVERRIDE; |
+ |
+ void JSEval(const std::string& script); |
+ |
+ void JSExpectAsync(const std::string& function); |
+ |
+ void JSSetTextField(const std::string& element_selector, |
+ const std::string& value); |
+ |
+ void PrepareUsers(); |
+ void StartFlowLoginAsManager(); |
+ void FillNewUserData(const std::string& display_name); |
+ void StartUserCreation(const std::string& button_id, |
+ const std::string& expected_display_name); |
+ void SigninAsSupervisedUser(bool check_homedir_calls, |
+ int user_index, |
+ const std::string& expected_display_name); |
+ void SigninAsManager(int user_index); |
+ void RemoveSupervisedUser(unsigned long original_user_count, |
+ int user_index, |
+ const std::string& expected_display_name); |
+ |
+ cryptohome::MockAsyncMethodCaller* mock_async_method_caller_; |
+ cryptohome::MockHomedirMethods* mock_homedir_methods_; |
+ NetworkPortalDetectorTestImpl* network_portal_detector_; |
+ ManagedUserRegistrationUtilityStub* registration_utility_stub_; |
+ scoped_ptr<ScopedTestingManagedUserRegistrationUtility> scoped_utility_; |
+ scoped_ptr<ManagedUsersSharedSettingsSyncTestAdapter> |
+ shared_settings_adapter_; |
+ scoped_ptr<ManagedUsersSyncTestAdapter> managed_users_adapter_; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(ManagedUserTestBase); |
+}; |
+ |
+} // namespace testing |
+ |
+} // namespace chromeos |
+ |
+#endif // CHROME_BROWSER_CHROMEOS_LOGIN_MANAGED_MANAGED_USER_TEST_BASE_H_ |