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

Side by Side Diff: chrome/browser/search/hotword_service_unittest.cc

Issue 196753002: [Hotword] Making enabling/disabling the setting enable/disable the hotword extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove is_app and test Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/search/hotword_service.cc ('k') | extensions/browser/admin_policy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/metrics/field_trial.h" 5 #include "base/metrics/field_trial.h"
6 #include "base/prefs/pref_service.h" 6 #include "base/prefs/pref_service.h"
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/search/hotword_service.h" 8 #include "chrome/browser/search/hotword_service.h"
9 #include "chrome/browser/search/hotword_service_factory.h" 9 #include "chrome/browser/search/hotword_service_factory.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
11 #include "chrome/test/base/testing_profile.h" 11 #include "chrome/test/base/testing_profile.h"
12 #include "content/public/test/test_browser_thread_bundle.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 class HotwordServiceTest : public testing::Test { 15 class HotwordServiceTest : public testing::Test {
15 protected: 16 protected:
16 HotwordServiceTest() : field_trial_list_(NULL) {} 17 HotwordServiceTest() : field_trial_list_(NULL) {}
17 virtual ~HotwordServiceTest() {} 18 virtual ~HotwordServiceTest() {}
18 19
19 void SetApplicationLocale(Profile* profile, const std::string& new_locale) { 20 void SetApplicationLocale(Profile* profile, const std::string& new_locale) {
20 #if defined(OS_CHROMEOS) 21 #if defined(OS_CHROMEOS)
21 // On ChromeOS locale is per-profile. 22 // On ChromeOS locale is per-profile.
22 profile->GetPrefs()->SetString(prefs::kApplicationLocale, new_locale); 23 profile->GetPrefs()->SetString(prefs::kApplicationLocale, new_locale);
23 #else 24 #else
24 g_browser_process->SetApplicationLocale(new_locale); 25 g_browser_process->SetApplicationLocale(new_locale);
25 #endif 26 #endif
26 } 27 }
27 28
28 private: 29 private:
29 base::FieldTrialList field_trial_list_; 30 base::FieldTrialList field_trial_list_;
31 content::TestBrowserThreadBundle thread_bundle_;
30 }; 32 };
31 33
32 TEST_F(HotwordServiceTest, ShouldShowOptInPopup) { 34 TEST_F(HotwordServiceTest, ShouldShowOptInPopup) {
33 TestingProfile::Builder profile_builder; 35 TestingProfile::Builder profile_builder;
34 TestingProfile::Builder otr_profile_builder; 36 TestingProfile::Builder otr_profile_builder;
35 otr_profile_builder.SetIncognito(); 37 otr_profile_builder.SetIncognito();
36 scoped_ptr<TestingProfile> profile = profile_builder.Build(); 38 scoped_ptr<TestingProfile> profile = profile_builder.Build();
37 scoped_ptr<TestingProfile> otr_profile = otr_profile_builder.Build(); 39 scoped_ptr<TestingProfile> otr_profile = otr_profile_builder.Build();
38 40
39 // Popup should not be shown for incognito profiles. 41 // Popup should not be shown for incognito profiles.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en-US"); 144 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en-US");
143 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); 145 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
144 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en_us"); 146 SetApplicationLocale(static_cast<Profile*>(profile.get()), "en_us");
145 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get())); 147 EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile.get()));
146 148
147 // Test that incognito even with a valid locale and valid field trial 149 // Test that incognito even with a valid locale and valid field trial
148 // still returns false. 150 // still returns false.
149 SetApplicationLocale(static_cast<Profile*>(otr_profile.get()), "en"); 151 SetApplicationLocale(static_cast<Profile*>(otr_profile.get()), "en");
150 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(otr_profile.get())); 152 EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(otr_profile.get()));
151 } 153 }
OLDNEW
« no previous file with comments | « chrome/browser/search/hotword_service.cc ('k') | extensions/browser/admin_policy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698