Chromium Code Reviews| 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 "base/run_loop.h" | |
| 11 #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.
| |
| 12 #include "base/threading/sequenced_worker_pool.h" | |
| 13 #include "chrome/browser/chrome_notification_types.h" | |
| 14 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | |
| 15 #include "chrome/browser/chromeos/login/login_manager_test.h" | |
| 16 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h " | |
| 17 #include "chrome/browser/chromeos/login/startup_utils.h" | |
| 18 #include "chrome/browser/chromeos/login/supervised_user_manager.h" | |
| 19 #include "chrome/browser/chromeos/login/webui_login_view.h" | |
| 20 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" | |
| 21 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" | |
| 22 #include "chrome/browser/managed_mode/managed_user_constants.h" | |
| 23 #include "chrome/browser/managed_mode/managed_user_registration_utility.h" | |
| 24 #include "chrome/browser/managed_mode/managed_user_registration_utility_stub.h" | |
| 25 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h" | |
| 26 #include "chrome/browser/managed_mode/managed_user_shared_settings_service_facto ry.h" | |
| 27 #include "chrome/browser/managed_mode/managed_user_sync_service.h" | |
| 28 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h" | |
| 29 #include "chromeos/cryptohome/mock_async_method_caller.h" | |
| 30 #include "chromeos/cryptohome/mock_homedir_methods.h" | |
| 31 #include "content/public/browser/notification_service.h" | |
| 32 #include "content/public/test/browser_test_utils.h" | |
| 33 #include "content/public/test/test_utils.h" | |
| 34 #include "sync/api/attachments/attachment_service_proxy_for_test.h" | |
| 35 #include "sync/api/fake_sync_change_processor.h" | |
| 36 #include "sync/api/sync_change.h" | |
| 37 #include "sync/api/sync_error_factory_mock.h" | |
| 38 #include "sync/protocol/sync.pb.h" | |
| 39 | |
| 40 namespace chromeos { | |
| 41 | |
| 42 namespace testing { | |
| 43 | |
| 44 const char kStubEthernetServicePath[] = "eth0"; | |
|
Nikita (slow)
2014/04/23 09:50:17
nit: Move to .cc
| |
| 45 | |
| 46 const char kTestManager[] = "test-manager@gmail.com"; | |
| 47 const char kTestOtherUser[] = "test-user@gmail.com"; | |
| 48 | |
| 49 const char kTestManagerPassword[] = "password"; | |
| 50 const char kTestSupervisedUserDisplayName[] = "John Doe"; | |
| 51 const char kTestSupervisedUserPassword[] = "simplepassword"; | |
| 52 | |
| 53 class ManagedUsersSyncTestAdapter { | |
| 54 public: | |
| 55 explicit ManagedUsersSyncTestAdapter(Profile* profile); | |
| 56 | |
| 57 bool HasChanges() { return !processor_->changes().empty(); } | |
| 58 | |
| 59 scoped_ptr< ::sync_pb::ManagedUserSpecifics> GetFirstChange(); | |
| 60 | |
| 61 void AddChange(const ::sync_pb::ManagedUserSpecifics& proto); | |
| 62 | |
| 63 syncer::FakeSyncChangeProcessor* processor_; | |
| 64 ManagedUserSyncService* service_; | |
| 65 int next_sync_data_id_; | |
| 66 }; | |
| 67 | |
| 68 class ManagedUsersSharedSettingsSyncTestAdapter { | |
| 69 public: | |
| 70 explicit ManagedUsersSharedSettingsSyncTestAdapter(Profile* profile); | |
| 71 | |
| 72 bool HasChanges() { return !processor_->changes().empty(); } | |
| 73 | |
| 74 scoped_ptr< ::sync_pb::ManagedUserSharedSettingSpecifics> GetFirstChange(); | |
| 75 | |
| 76 void AddChange(const ::sync_pb::ManagedUserSharedSettingSpecifics& proto); | |
| 77 | |
| 78 void AddChange(const std::string& mu_id, | |
| 79 const std::string& key, | |
| 80 const base::Value& value, | |
| 81 bool acknowledged); | |
| 82 | |
| 83 syncer::FakeSyncChangeProcessor* processor_; | |
| 84 ManagedUserSharedSettingsService* service_; | |
| 85 int next_sync_data_id_; | |
| 86 }; | |
| 87 | |
| 88 class ManagedUserTestBase : public chromeos::LoginManagerTest { | |
| 89 public: | |
| 90 ManagedUserTestBase(); | |
| 91 virtual ~ManagedUserTestBase(); | |
| 92 | |
| 93 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; | |
| 94 virtual void CleanUpOnMainThread() OVERRIDE; | |
| 95 | |
| 96 protected: | |
| 97 virtual void TearDown() OVERRIDE; | |
| 98 | |
| 99 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE; | |
| 100 | |
| 101 void JSEval(const std::string& script); | |
| 102 | |
| 103 void JSExpectAsync(const std::string& function); | |
| 104 | |
| 105 void JSSetTextField(const std::string& element_selector, | |
| 106 const std::string& value); | |
| 107 | |
| 108 void PrepareUsers(); | |
| 109 void StartFlowLoginAsManager(); | |
| 110 void FillNewUserData(const std::string& display_name); | |
| 111 void StartUserCreation(const std::string& button_id, | |
| 112 const std::string& expected_display_name); | |
| 113 void SigninAsSupervisedUser(bool check_homedir_calls, | |
| 114 int user_index, | |
| 115 const std::string& expected_display_name); | |
| 116 void SigninAsManager(int user_index); | |
| 117 void RemoveSupervisedUser(unsigned long original_user_count, | |
| 118 int user_index, | |
| 119 const std::string& expected_display_name); | |
| 120 | |
| 121 cryptohome::MockAsyncMethodCaller* mock_async_method_caller_; | |
| 122 cryptohome::MockHomedirMethods* mock_homedir_methods_; | |
| 123 NetworkPortalDetectorTestImpl* network_portal_detector_; | |
| 124 ManagedUserRegistrationUtilityStub* registration_utility_stub_; | |
| 125 scoped_ptr<ScopedTestingManagedUserRegistrationUtility> scoped_utility_; | |
| 126 scoped_ptr<ManagedUsersSharedSettingsSyncTestAdapter> | |
| 127 shared_settings_adapter_; | |
| 128 scoped_ptr<ManagedUsersSyncTestAdapter> managed_users_adapter_; | |
| 129 | |
| 130 private: | |
| 131 DISALLOW_COPY_AND_ASSIGN(ManagedUserTestBase); | |
| 132 }; | |
| 133 | |
| 134 } // namespace testing | |
| 135 | |
| 136 } // namespace chromeos | |
| 137 | |
| 138 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MANAGED_MANAGED_USER_TEST_BASE_H_ | |
| OLD | NEW |