Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(782)

Side by Side Diff: chrome/browser/supervised_user/legacy/supervised_user_pref_mapping_service_unittest.cc

Issue 1086733002: Ensure tests have an active task runner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/supervised_user/legacy/supervised_user_pref_mapping_ser vice.h" 8 #include "chrome/browser/supervised_user/legacy/supervised_user_pref_mapping_ser vice.h"
9 #include "chrome/browser/supervised_user/legacy/supervised_user_pref_mapping_ser vice_factory.h" 9 #include "chrome/browser/supervised_user/legacy/supervised_user_pref_mapping_ser vice_factory.h"
10 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_ service.h" 10 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_ service.h"
11 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_ service_factory.h" 11 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_ service_factory.h"
12 #include "chrome/browser/supervised_user/supervised_user_constants.h" 12 #include "chrome/browser/supervised_user/supervised_user_constants.h"
13 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
14 #include "chrome/test/base/testing_profile.h" 14 #include "chrome/test/base/testing_profile.h"
15 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 const char kFakeSupervisedUserId[] = "fakeID"; 18 const char kFakeSupervisedUserId[] = "fakeID";
18 19
19 class SupervisedUserPrefMappingServiceTest : public ::testing::Test { 20 class SupervisedUserPrefMappingServiceTest : public ::testing::Test {
20 protected: 21 protected:
21 SupervisedUserPrefMappingServiceTest() { 22 SupervisedUserPrefMappingServiceTest() {
22 profile_.GetPrefs()->SetString(prefs::kSupervisedUserId, 23 profile_.GetPrefs()->SetString(prefs::kSupervisedUserId,
23 kFakeSupervisedUserId); 24 kFakeSupervisedUserId);
24 shared_settings_service_ = 25 shared_settings_service_ =
25 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext( 26 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
26 &profile_); 27 &profile_);
27 mapping_service_ = 28 mapping_service_ =
28 SupervisedUserPrefMappingServiceFactory::GetForBrowserContext( 29 SupervisedUserPrefMappingServiceFactory::GetForBrowserContext(
29 &profile_); 30 &profile_);
30 } 31 }
31 ~SupervisedUserPrefMappingServiceTest() override {} 32 ~SupervisedUserPrefMappingServiceTest() override {}
32 33
33 // testing::Test overrides: 34 // testing::Test overrides:
34 void SetUp() override { mapping_service_->Init(); } 35 void SetUp() override { mapping_service_->Init(); }
35 36
36 void TearDown() override { 37 void TearDown() override {
37 mapping_service_->Shutdown(); 38 mapping_service_->Shutdown();
38 shared_settings_service_->Shutdown(); 39 shared_settings_service_->Shutdown();
39 } 40 }
40 41
42 content::TestBrowserThreadBundle thread_bundle_;
41 TestingProfile profile_; 43 TestingProfile profile_;
42 SupervisedUserSharedSettingsService* shared_settings_service_; 44 SupervisedUserSharedSettingsService* shared_settings_service_;
43 SupervisedUserPrefMappingService* mapping_service_; 45 SupervisedUserPrefMappingService* mapping_service_;
44 }; 46 };
45 47
46 TEST_F(SupervisedUserPrefMappingServiceTest, CheckPrefUpdate) { 48 TEST_F(SupervisedUserPrefMappingServiceTest, CheckPrefUpdate) {
47 EXPECT_TRUE(shared_settings_service_->GetValue( 49 EXPECT_TRUE(shared_settings_service_->GetValue(
48 kFakeSupervisedUserId, 50 kFakeSupervisedUserId,
49 supervised_users::kChromeAvatarIndex) == NULL); 51 supervised_users::kChromeAvatarIndex) == NULL);
50 profile_.GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, 4); 52 profile_.GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, 4);
51 const base::Value* value = shared_settings_service_->GetValue( 53 const base::Value* value = shared_settings_service_->GetValue(
52 kFakeSupervisedUserId, supervised_users::kChromeAvatarIndex); 54 kFakeSupervisedUserId, supervised_users::kChromeAvatarIndex);
53 int avatar_index; 55 int avatar_index;
54 value->GetAsInteger(&avatar_index); 56 value->GetAsInteger(&avatar_index);
55 EXPECT_EQ(avatar_index, 4); 57 EXPECT_EQ(avatar_index, 4);
56 } 58 }
57 59
58 TEST_F(SupervisedUserPrefMappingServiceTest, CheckSharedSettingUpdate) { 60 TEST_F(SupervisedUserPrefMappingServiceTest, CheckSharedSettingUpdate) {
59 EXPECT_EQ(profile_.GetPrefs()->GetInteger(prefs::kProfileAvatarIndex), -1); 61 EXPECT_EQ(profile_.GetPrefs()->GetInteger(prefs::kProfileAvatarIndex), -1);
60 shared_settings_service_->SetValue(kFakeSupervisedUserId, 62 shared_settings_service_->SetValue(kFakeSupervisedUserId,
61 supervised_users::kChromeAvatarIndex, 63 supervised_users::kChromeAvatarIndex,
62 base::FundamentalValue(1)); 64 base::FundamentalValue(1));
63 mapping_service_->OnSharedSettingChanged( 65 mapping_service_->OnSharedSettingChanged(
64 kFakeSupervisedUserId, 66 kFakeSupervisedUserId,
65 supervised_users::kChromeAvatarIndex); 67 supervised_users::kChromeAvatarIndex);
66 EXPECT_EQ(profile_.GetPrefs()->GetInteger(prefs::kProfileAvatarIndex), 1); 68 EXPECT_EQ(profile_.GetPrefs()->GetInteger(prefs::kProfileAvatarIndex), 1);
67 } 69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698