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

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

Issue 8956059: Rename NavigationController to NavigationControllerImpl and put it into the content namespace. Al... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 12 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/rlz/rlz.cc ('k') | chrome/browser/safe_browsing/browser_feature_extractor.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/test/test_reg_util_win.h" 10 #include "base/test/test_reg_util_win.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "base/win/registry.h" 12 #include "base/win/registry.h"
13 #include "chrome/browser/autocomplete/autocomplete.h" 13 #include "chrome/browser/autocomplete/autocomplete.h"
14 #include "chrome/browser/google/google_util.h" 14 #include "chrome/browser/google/google_util.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/common/env_vars.h" 17 #include "chrome/common/env_vars.h"
18 #include "chrome/installer/util/browser_distribution.h" 18 #include "chrome/installer/util/browser_distribution.h"
19 #include "chrome/installer/util/google_update_constants.h" 19 #include "chrome/installer/util/google_update_constants.h"
20 #include "content/public/browser/navigation_entry.h" 20 #include "content/public/browser/navigation_entry.h"
21 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
22 #include "content/public/browser/notification_details.h" 22 #include "content/public/browser/notification_details.h"
23 #include "content/public/browser/notification_source.h" 23 #include "content/public/browser/notification_source.h"
24 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
25 25
26 using base::win::RegKey; 26 using base::win::RegKey;
27 using content::NavigationEntry;
27 using registry_util::RegistryOverrideManager; 28 using registry_util::RegistryOverrideManager;
28 using testing::AssertionResult; 29 using testing::AssertionResult;
29 using testing::AssertionSuccess; 30 using testing::AssertionSuccess;
30 using testing::AssertionFailure; 31 using testing::AssertionFailure;
31 32
32 namespace { 33 namespace {
33 34
34 // Registry path to overridden hive. 35 // Registry path to overridden hive.
35 const wchar_t kRlzTempHkcu[] = L"rlz_hkcu"; 36 const wchar_t kRlzTempHkcu[] = L"rlz_hkcu";
36 const wchar_t kRlzTempHklm[] = L"rlz_hklm"; 37 const wchar_t kRlzTempHklm[] = L"rlz_hklm";
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 231 }
231 } 232 }
232 233
233 void RlzLibTest::SimulateOmniboxUsage() { 234 void RlzLibTest::SimulateOmniboxUsage() {
234 tracker_.Observe(chrome::NOTIFICATION_OMNIBOX_OPENED_URL, 235 tracker_.Observe(chrome::NOTIFICATION_OMNIBOX_OPENED_URL,
235 content::NotificationService::AllSources(), 236 content::NotificationService::AllSources(),
236 content::Details<AutocompleteLog>(NULL)); 237 content::Details<AutocompleteLog>(NULL));
237 } 238 }
238 239
239 void RlzLibTest::SimulateHomepageUsage() { 240 void RlzLibTest::SimulateHomepageUsage() {
240 scoped_ptr<content::NavigationEntry> entry( 241 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create());
241 content::NavigationEntry::Create());
242 entry->SetPageID(0); 242 entry->SetPageID(0);
243 entry->SetTransitionType(content::PAGE_TRANSITION_HOME_PAGE); 243 entry->SetTransitionType(content::PAGE_TRANSITION_HOME_PAGE);
244 tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING, 244 tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING,
245 content::NotificationService::AllSources(), 245 content::NotificationService::AllSources(),
246 content::Details<content::NavigationEntry>(entry.get())); 246 content::Details<NavigationEntry>(entry.get()));
247 } 247 }
248 248
249 void RlzLibTest::InvokeDelayedInit() { 249 void RlzLibTest::InvokeDelayedInit() {
250 tracker_.DelayedInit(); 250 tracker_.DelayedInit();
251 } 251 }
252 252
253 void RlzLibTest::ExpectEventRecorded(const char* event_name, bool expected) { 253 void RlzLibTest::ExpectEventRecorded(const char* event_name, bool expected) {
254 char cgi[rlz_lib::kMaxCgiLength]; 254 char cgi[rlz_lib::kMaxCgiLength];
255 GetProductEventsAsCgi(rlz_lib::CHROME, cgi, arraysize(cgi)); 255 GetProductEventsAsCgi(rlz_lib::CHROME, cgi, arraysize(cgi));
256 if (expected) { 256 if (expected) {
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 // Make sure cache is now updated. 575 // Make sure cache is now updated.
576 tracker_.set_assume_not_ui_thread(false); 576 tracker_.set_assume_not_ui_thread(false);
577 577
578 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz)); 578 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz));
579 EXPECT_STREQ(kNewOmniboxRlzString, WideToUTF8(rlz).c_str()); 579 EXPECT_STREQ(kNewOmniboxRlzString, WideToUTF8(rlz).c_str());
580 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, &rlz)); 580 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, &rlz));
581 EXPECT_STREQ(kNewHomepageRlzString, WideToUTF8(rlz).c_str()); 581 EXPECT_STREQ(kNewHomepageRlzString, WideToUTF8(rlz).c_str());
582 } 582 }
583 583
584 TEST_F(RlzLibTest, ObserveHandlesBadArgs) { 584 TEST_F(RlzLibTest, ObserveHandlesBadArgs) {
585 scoped_ptr<content::NavigationEntry> entry( 585 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create());
586 content::NavigationEntry::Create());
587 entry->SetPageID(0); 586 entry->SetPageID(0);
588 entry->SetTransitionType(content::PAGE_TRANSITION_LINK); 587 entry->SetTransitionType(content::PAGE_TRANSITION_LINK);
589 tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING, 588 tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING,
590 content::NotificationService::AllSources(), 589 content::NotificationService::AllSources(),
591 content::Details<content::NavigationEntry>(NULL)); 590 content::Details<NavigationEntry>(NULL));
592 tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING, 591 tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING,
593 content::NotificationService::AllSources(), 592 content::NotificationService::AllSources(),
594 content::Details<content::NavigationEntry>(entry.get())); 593 content::Details<NavigationEntry>(entry.get()));
595 } 594 }
596 595
597 TEST_F(RlzLibTest, ReactivationNonOrganicNonOrganic) { 596 TEST_F(RlzLibTest, ReactivationNonOrganicNonOrganic) {
598 SetReactivationBrand("REAC"); 597 SetReactivationBrand("REAC");
599 598
600 RLZTracker::InitRlzDelayed(true, 20, true, true); 599 RLZTracker::InitRlzDelayed(true, 20, true, true);
601 InvokeDelayedInit(); 600 InvokeDelayedInit();
602 601
603 ExpectRlzPingSent(true); 602 ExpectRlzPingSent(true);
604 ExpectReactivationRlzPingSent(true); 603 ExpectReactivationRlzPingSent(true);
(...skipping 25 matching lines...) Expand all
630 SetMainBrand("GGLS"); 629 SetMainBrand("GGLS");
631 SetReactivationBrand("GGRS"); 630 SetReactivationBrand("GGRS");
632 631
633 RLZTracker::InitRlzDelayed(true, 20, true, true); 632 RLZTracker::InitRlzDelayed(true, 20, true, true);
634 InvokeDelayedInit(); 633 InvokeDelayedInit();
635 634
636 ExpectRlzPingSent(false); 635 ExpectRlzPingSent(false);
637 ExpectReactivationRlzPingSent(false); 636 ExpectReactivationRlzPingSent(false);
638 } 637 }
639 638
OLDNEW
« no previous file with comments | « chrome/browser/rlz/rlz.cc ('k') | chrome/browser/safe_browsing/browser_feature_extractor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698