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

Side by Side Diff: chrome/browser/rlz/rlz_unittest.cc

Issue 316963002: Move branding information out of google_util (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 6 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/rlz/rlz.h" 5 #include "chrome/browser/rlz/rlz.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "chrome/browser/autocomplete/autocomplete_controller.h" 10 #include "chrome/browser/autocomplete/autocomplete_controller.h"
11 #include "chrome/browser/autocomplete/autocomplete_input.h" 11 #include "chrome/browser/autocomplete/autocomplete_input.h"
12 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/google/google_brand.h"
13 #include "chrome/browser/google/google_util.h" 14 #include "chrome/browser/google/google_util.h"
14 #include "chrome/browser/omnibox/omnibox_log.h" 15 #include "chrome/browser/omnibox/omnibox_log.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/installer/util/browser_distribution.h" 17 #include "chrome/installer/util/browser_distribution.h"
17 #include "chrome/installer/util/google_update_constants.h" 18 #include "chrome/installer/util/google_update_constants.h"
18 #include "content/public/browser/navigation_entry.h" 19 #include "content/public/browser/navigation_entry.h"
19 #include "content/public/browser/notification_details.h" 20 #include "content/public/browser/notification_details.h"
20 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
21 #include "content/public/browser/notification_source.h" 22 #include "content/public/browser/notification_source.h"
22 #include "rlz/test/rlz_test_helpers.h" 23 #include "rlz/test/rlz_test_helpers.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 void SimulateHomepageUsage(); 176 void SimulateHomepageUsage();
176 void SimulateAppListUsage(); 177 void SimulateAppListUsage();
177 void InvokeDelayedInit(); 178 void InvokeDelayedInit();
178 179
179 void ExpectEventRecorded(const char* event_name, bool expected); 180 void ExpectEventRecorded(const char* event_name, bool expected);
180 void ExpectRlzPingSent(bool expected); 181 void ExpectRlzPingSent(bool expected);
181 void ExpectReactivationRlzPingSent(bool expected); 182 void ExpectReactivationRlzPingSent(bool expected);
182 183
183 TestRLZTracker tracker_; 184 TestRLZTracker tracker_;
184 #if defined(OS_POSIX) 185 #if defined(OS_POSIX)
185 scoped_ptr<google_util::BrandForTesting> brand_override_; 186 scoped_ptr<google_brand::BrandForTesting> brand_override_;
186 #endif 187 #endif
187 }; 188 };
188 189
189 void RlzLibTest::SetUp() { 190 void RlzLibTest::SetUp() {
190 RlzLibTestNoMachineState::SetUp(); 191 RlzLibTestNoMachineState::SetUp();
191 192
192 // Make sure a non-organic brand code is set in the registry or the RLZTracker 193 // Make sure a non-organic brand code is set in the registry or the RLZTracker
193 // is pretty much a no-op. 194 // is pretty much a no-op.
194 SetMainBrand("TEST"); 195 SetMainBrand("TEST");
195 SetReactivationBrand(""); 196 SetReactivationBrand("");
196 } 197 }
197 198
198 void RlzLibTest::SetMainBrand(const char* brand) { 199 void RlzLibTest::SetMainBrand(const char* brand) {
199 #if defined(OS_WIN) 200 #if defined(OS_WIN)
200 SetRegistryBrandValue(google_update::kRegRLZBrandField, brand); 201 SetRegistryBrandValue(google_update::kRegRLZBrandField, brand);
201 #elif defined(OS_POSIX) 202 #elif defined(OS_POSIX)
202 brand_override_.reset(new google_util::BrandForTesting(brand)); 203 brand_override_.reset(new google_brand::BrandForTesting(brand));
203 #endif 204 #endif
204 std::string check_brand; 205 std::string check_brand;
205 google_util::GetBrand(&check_brand); 206 google_brand::GetBrand(&check_brand);
206 EXPECT_EQ(brand, check_brand); 207 EXPECT_EQ(brand, check_brand);
207 } 208 }
208 209
209 void RlzLibTest::SetReactivationBrand(const char* brand) { 210 void RlzLibTest::SetReactivationBrand(const char* brand) {
210 // TODO(thakis): Reactivation doesn't exist on Mac yet. 211 // TODO(thakis): Reactivation doesn't exist on Mac yet.
211 #if defined(OS_WIN) 212 #if defined(OS_WIN)
212 SetRegistryBrandValue(google_update::kRegRLZReactivationBrandField, brand); 213 SetRegistryBrandValue(google_update::kRegRLZReactivationBrandField, brand);
213 std::string check_brand; 214 std::string check_brand;
214 google_util::GetReactivationBrand(&check_brand); 215 google_brand::GetReactivationBrand(&check_brand);
215 EXPECT_EQ(brand, check_brand); 216 EXPECT_EQ(brand, check_brand);
216 #endif 217 #endif
217 } 218 }
218 219
219 #if defined(OS_WIN) 220 #if defined(OS_WIN)
220 void RlzLibTest::SetRegistryBrandValue(const wchar_t* name, 221 void RlzLibTest::SetRegistryBrandValue(const wchar_t* name,
221 const char* brand) { 222 const char* brand) {
222 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 223 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
223 base::string16 reg_path = dist->GetStateKey(); 224 base::string16 reg_path = dist->GetStateKey();
224 RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_SET_VALUE); 225 RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_SET_VALUE);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 GetProductEventsAsCgi(rlz_lib::CHROME, cgi, arraysize(cgi)); 272 GetProductEventsAsCgi(rlz_lib::CHROME, cgi, arraysize(cgi));
272 if (expected) { 273 if (expected) {
273 EXPECT_STR_CONTAINS(cgi, event_name); 274 EXPECT_STR_CONTAINS(cgi, event_name);
274 } else { 275 } else {
275 EXPECT_STR_NOT_CONTAIN(cgi, event_name); 276 EXPECT_STR_NOT_CONTAIN(cgi, event_name);
276 } 277 }
277 } 278 }
278 279
279 void RlzLibTest::ExpectRlzPingSent(bool expected) { 280 void RlzLibTest::ExpectRlzPingSent(bool expected) {
280 std::string brand; 281 std::string brand;
281 google_util::GetBrand(&brand); 282 google_brand::GetBrand(&brand);
282 EXPECT_EQ(expected, tracker_.was_ping_sent_for_brand(brand.c_str())); 283 EXPECT_EQ(expected, tracker_.was_ping_sent_for_brand(brand.c_str()));
283 } 284 }
284 285
285 void RlzLibTest::ExpectReactivationRlzPingSent(bool expected) { 286 void RlzLibTest::ExpectReactivationRlzPingSent(bool expected) {
286 std::string brand; 287 std::string brand;
287 google_util::GetReactivationBrand(&brand); 288 google_brand::GetReactivationBrand(&brand);
288 EXPECT_EQ(expected, tracker_.was_ping_sent_for_brand(brand.c_str())); 289 EXPECT_EQ(expected, tracker_.was_ping_sent_for_brand(brand.c_str()));
289 } 290 }
290 291
291 // The events that affect the different RLZ scenarios are the following: 292 // The events that affect the different RLZ scenarios are the following:
292 // 293 //
293 // A: the user starts chrome for the first time 294 // A: the user starts chrome for the first time
294 // B: the user stops chrome 295 // B: the user stops chrome
295 // C: the user start a subsequent time 296 // C: the user start a subsequent time
296 // D: the user stops chrome again 297 // D: the user stops chrome again
297 // I: the RLZTracker::DelayedInit() method is invoked 298 // I: the RLZTracker::DelayedInit() method is invoked
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 RLZTracker::RecordProductEvent(rlz_lib::CHROME, RLZTracker::ChromeOmnibox(), 888 RLZTracker::RecordProductEvent(rlz_lib::CHROME, RLZTracker::ChromeOmnibox(),
888 rlz_lib::FIRST_SEARCH); 889 rlz_lib::FIRST_SEARCH);
889 890
890 ExpectEventRecorded(kOmniboxFirstSearch, true); 891 ExpectEventRecorded(kOmniboxFirstSearch, true);
891 892
892 RLZTracker::ClearRlzState(); 893 RLZTracker::ClearRlzState();
893 894
894 ExpectEventRecorded(kOmniboxFirstSearch, false); 895 ExpectEventRecorded(kOmniboxFirstSearch, false);
895 } 896 }
896 #endif // defined(OS_CHROMEOS) 897 #endif // defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698