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

Side by Side Diff: components/translate/core/browser/translate_manager_unittest.cc

Issue 2782553004: Move TestingPrefService to use unique_ptr<Value> (Closed)
Patch Set: comments Created 3 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/translate/core/browser/translate_manager.h" 5 #include "components/translate/core/browser/translate_manager.h"
6 6
7 #include <utility>
8
7 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
8 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
9 #include "base/run_loop.h" 11 #include "base/run_loop.h"
10 #include "base/test/histogram_tester.h" 12 #include "base/test/histogram_tester.h"
11 #include "base/test/scoped_feature_list.h" 13 #include "base/test/scoped_feature_list.h"
12 #include "build/build_config.h" 14 #include "build/build_config.h"
13 #include "components/infobars/core/infobar.h" 15 #include "components/infobars/core/infobar.h"
14 #include "components/pref_registry/pref_registry_syncable.h" 16 #include "components/pref_registry/pref_registry_syncable.h"
15 #include "components/sync_preferences/testing_pref_service_syncable.h" 17 #include "components/sync_preferences/testing_pref_service_syncable.h"
16 #include "components/translate/core/browser/mock_translate_driver.h" 18 #include "components/translate/core/browser/mock_translate_driver.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 TranslateManager::SetIgnoreMissingKeyForTesting(true); 167 TranslateManager::SetIgnoreMissingKeyForTesting(true);
166 translate_manager_.reset(new translate::TranslateManager( 168 translate_manager_.reset(new translate::TranslateManager(
167 &mock_translate_client_, kAcceptLanguages)); 169 &mock_translate_client_, kAcceptLanguages));
168 } 170 }
169 171
170 // Prepare the test for ULP related tests. 172 // Prepare the test for ULP related tests.
171 // Put the ulp json into profile. 173 // Put the ulp json into profile.
172 void PrepareULPTest(const char* ulp_json, bool turn_on_feature) { 174 void PrepareULPTest(const char* ulp_json, bool turn_on_feature) {
173 PrepareTranslateManager(); 175 PrepareTranslateManager();
174 std::unique_ptr<base::Value> profile(CreateProfileFromJSON(ulp_json)); 176 std::unique_ptr<base::Value> profile(CreateProfileFromJSON(ulp_json));
175 prefs_.SetUserPref(TranslatePrefs::kPrefLanguageProfile, profile.release()); 177 prefs_.SetUserPref(TranslatePrefs::kPrefLanguageProfile,
178 std::move(profile));
176 if (turn_on_feature) 179 if (turn_on_feature)
177 TurnOnTranslateByULP(); 180 TurnOnTranslateByULP();
178 } 181 }
179 182
180 std::unique_ptr<base::Value> CreateProfileFromJSON(const char* json) { 183 std::unique_ptr<base::Value> CreateProfileFromJSON(const char* json) {
181 int error_code = 0; 184 int error_code = 0;
182 std::string error_msg; 185 std::string error_msg;
183 int error_line = 0; 186 int error_line = 0;
184 int error_column = 0; 187 int error_column = 0;
185 188
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 // 0.79 and lower than 0.8 and the probability threshold is lower than both 448 // 0.79 and lower than 0.8 and the probability threshold is lower than both
446 // the one with "fr" (0.6) and "pt-PT" (0.4). 449 // the one with "fr" (0.6) and "pt-PT" (0.4).
447 EXPECT_TRUE(CallLanguageInULP("fr")); 450 EXPECT_TRUE(CallLanguageInULP("fr"));
448 EXPECT_TRUE(CallLanguageInULP("pt")); 451 EXPECT_TRUE(CallLanguageInULP("pt"));
449 EXPECT_FALSE(CallLanguageInULP("zh-TW")); 452 EXPECT_FALSE(CallLanguageInULP("zh-TW"));
450 } 453 }
451 454
452 } // namespace testing 455 } // namespace testing
453 456
454 } // namespace translate 457 } // namespace translate
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698