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_SUPERVISED_SUPERVISED_USER_TEST_BASE_H_
5 #define CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_SUPERVISED_USER_TEST_BASE_H_
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_stub.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"
23 const char kTestManager
[] = "test-manager@gmail.com";
24 const char kTestOtherUser
[] = "test-user@gmail.com";
26 const char kTestManagerPassword
[] = "password";
27 const char kTestSupervisedUserDisplayName
[] = "John Doe";
28 const char kTestSupervisedUserPassword
[] = "simplepassword";
30 class SupervisedUsersSyncTestAdapter
{
32 explicit SupervisedUsersSyncTestAdapter(Profile
* profile
);
34 bool HasChanges() { return !processor_
->changes().empty(); }
36 scoped_ptr
< ::sync_pb::ManagedUserSpecifics
> GetFirstChange();
38 void AddChange(const ::sync_pb::ManagedUserSpecifics
& proto
, bool update
);
40 syncer::FakeSyncChangeProcessor
* processor_
;
41 SupervisedUserSyncService
* service_
;
42 int next_sync_data_id_
;
45 class SupervisedUsersSharedSettingsSyncTestAdapter
{
47 explicit SupervisedUsersSharedSettingsSyncTestAdapter(Profile
* profile
);
49 bool HasChanges() { return !processor_
->changes().empty(); }
51 scoped_ptr
< ::sync_pb::ManagedUserSharedSettingSpecifics
> GetFirstChange();
53 void AddChange(const ::sync_pb::ManagedUserSharedSettingSpecifics
& proto
,
56 void AddChange(const std::string
& mu_id
,
57 const std::string
& key
,
58 const base::Value
& value
,
62 syncer::FakeSyncChangeProcessor
* processor_
;
63 SupervisedUserSharedSettingsService
* service_
;
64 int next_sync_data_id_
;
67 class SupervisedUserTestBase
: public chromeos::LoginManagerTest
{
69 SupervisedUserTestBase();
70 virtual ~SupervisedUserTestBase();
72 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE
;
73 virtual void CleanUpOnMainThread() OVERRIDE
;
76 virtual void TearDown() OVERRIDE
;
78 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE
;
80 void JSEval(const std::string
& script
);
82 void JSExpectAsync(const std::string
& function
);
84 void JSSetTextField(const std::string
& element_selector
,
85 const std::string
& value
);
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
,
94 const std::string
& expected_display_name
);
95 void SigninAsManager(int user_index
);
96 void RemoveSupervisedUser(unsigned long original_user_count
,
98 const std::string
& expected_display_name
);
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
<SupervisedUsersSharedSettingsSyncTestAdapter
>
106 shared_settings_adapter_
;
107 scoped_ptr
<SupervisedUsersSyncTestAdapter
> supervised_users_adapter_
;
110 DISALLOW_COPY_AND_ASSIGN(SupervisedUserTestBase
);
113 } // namespace chromeos
115 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_SUPERVISED_USER_TEST_BASE_H_