| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MANAGED_MANAGED_USER_TEST_BASE_H_ | |
| 5 #define CHROME_BROWSER_CHROMEOS_LOGIN_MANAGED_MANAGED_USER_TEST_BASE_H_ | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "chrome/browser/chromeos/login/login_manager_test.h" | |
| 11 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" | |
| 12 #include "chrome/browser/profiles/profile.h" | |
| 13 #include "chrome/browser/supervised_user/supervised_user_registration_utility_st
ub.h" | |
| 14 #include "chromeos/cryptohome/mock_async_method_caller.h" | |
| 15 #include "chromeos/cryptohome/mock_homedir_methods.h" | |
| 16 #include "sync/api/fake_sync_change_processor.h" | |
| 17 #include "sync/api/sync_change.h" | |
| 18 #include "sync/api/sync_error_factory_mock.h" | |
| 19 #include "sync/protocol/sync.pb.h" | |
| 20 | |
| 21 namespace chromeos { | |
| 22 | |
| 23 const char kTestManager[] = "test-manager@gmail.com"; | |
| 24 const char kTestOtherUser[] = "test-user@gmail.com"; | |
| 25 | |
| 26 const char kTestManagerPassword[] = "password"; | |
| 27 const char kTestSupervisedUserDisplayName[] = "John Doe"; | |
| 28 const char kTestSupervisedUserPassword[] = "simplepassword"; | |
| 29 | |
| 30 class ManagedUsersSyncTestAdapter { | |
| 31 public: | |
| 32 explicit ManagedUsersSyncTestAdapter(Profile* profile); | |
| 33 | |
| 34 bool HasChanges() { return !processor_->changes().empty(); } | |
| 35 | |
| 36 scoped_ptr< ::sync_pb::ManagedUserSpecifics> GetFirstChange(); | |
| 37 | |
| 38 void AddChange(const ::sync_pb::ManagedUserSpecifics& proto, bool update); | |
| 39 | |
| 40 syncer::FakeSyncChangeProcessor* processor_; | |
| 41 SupervisedUserSyncService* service_; | |
| 42 int next_sync_data_id_; | |
| 43 }; | |
| 44 | |
| 45 class ManagedUsersSharedSettingsSyncTestAdapter { | |
| 46 public: | |
| 47 explicit ManagedUsersSharedSettingsSyncTestAdapter(Profile* profile); | |
| 48 | |
| 49 bool HasChanges() { return !processor_->changes().empty(); } | |
| 50 | |
| 51 scoped_ptr< ::sync_pb::ManagedUserSharedSettingSpecifics> GetFirstChange(); | |
| 52 | |
| 53 void AddChange(const ::sync_pb::ManagedUserSharedSettingSpecifics& proto, | |
| 54 bool update); | |
| 55 | |
| 56 void AddChange(const std::string& mu_id, | |
| 57 const std::string& key, | |
| 58 const base::Value& value, | |
| 59 bool acknowledged, | |
| 60 bool update); | |
| 61 | |
| 62 syncer::FakeSyncChangeProcessor* processor_; | |
| 63 SupervisedUserSharedSettingsService* service_; | |
| 64 int next_sync_data_id_; | |
| 65 }; | |
| 66 | |
| 67 class ManagedUserTestBase : public chromeos::LoginManagerTest { | |
| 68 public: | |
| 69 ManagedUserTestBase(); | |
| 70 virtual ~ManagedUserTestBase(); | |
| 71 | |
| 72 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; | |
| 73 virtual void CleanUpOnMainThread() OVERRIDE; | |
| 74 | |
| 75 protected: | |
| 76 virtual void TearDown() OVERRIDE; | |
| 77 | |
| 78 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE; | |
| 79 | |
| 80 void JSEval(const std::string& script); | |
| 81 | |
| 82 void JSExpectAsync(const std::string& function); | |
| 83 | |
| 84 void JSSetTextField(const std::string& element_selector, | |
| 85 const std::string& value); | |
| 86 | |
| 87 void PrepareUsers(); | |
| 88 void StartFlowLoginAsManager(); | |
| 89 void FillNewUserData(const std::string& display_name); | |
| 90 void StartUserCreation(const std::string& button_id, | |
| 91 const std::string& expected_display_name); | |
| 92 void SigninAsSupervisedUser(bool check_homedir_calls, | |
| 93 int user_index, | |
| 94 const std::string& expected_display_name); | |
| 95 void SigninAsManager(int user_index); | |
| 96 void RemoveSupervisedUser(unsigned long original_user_count, | |
| 97 int user_index, | |
| 98 const std::string& expected_display_name); | |
| 99 | |
| 100 cryptohome::MockAsyncMethodCaller* mock_async_method_caller_; | |
| 101 cryptohome::MockHomedirMethods* mock_homedir_methods_; | |
| 102 NetworkPortalDetectorTestImpl* network_portal_detector_; | |
| 103 SupervisedUserRegistrationUtilityStub* registration_utility_stub_; | |
| 104 scoped_ptr<ScopedTestingSupervisedUserRegistrationUtility> scoped_utility_; | |
| 105 scoped_ptr<ManagedUsersSharedSettingsSyncTestAdapter> | |
| 106 shared_settings_adapter_; | |
| 107 scoped_ptr<ManagedUsersSyncTestAdapter> managed_users_adapter_; | |
| 108 | |
| 109 private: | |
| 110 DISALLOW_COPY_AND_ASSIGN(ManagedUserTestBase); | |
| 111 }; | |
| 112 | |
| 113 } // namespace chromeos | |
| 114 | |
| 115 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MANAGED_MANAGED_USER_TEST_BASE_H_ | |
| OLD | NEW |