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