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

Unified Diff: chrome/browser/rlz/rlz_unittest.cc

Issue 591483002: Only send C2F ping for a search through homepage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/rlz/rlz.cc ('k') | rlz/lib/rlz_lib_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/rlz/rlz_unittest.cc
diff --git a/chrome/browser/rlz/rlz_unittest.cc b/chrome/browser/rlz/rlz_unittest.cc
index 83c422a7ab38014919dce594ff4f6524fe1d07cb..5560a2fc500cc762f78d5aa1305822d69aaf59ad 100644
--- a/chrome/browser/rlz/rlz_unittest.cc
+++ b/chrome/browser/rlz/rlz_unittest.cc
@@ -14,19 +14,24 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/google_update_constants.h"
+#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "components/metrics/proto/omnibox_event.pb.h"
+#include "content/public/browser/navigation_details.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
+#include "content/public/test/test_renderer_host.h"
#include "rlz/test/rlz_test_helpers.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "url/gurl.h"
#if defined(OS_WIN)
#include "base/win/registry.h"
#endif
using content::NavigationEntry;
+using content::LoadCommittedDetails;
using testing::AssertionResult;
using testing::AssertionSuccess;
using testing::AssertionFailure;
@@ -161,9 +166,10 @@ class TestRLZTracker : public RLZTracker {
DISALLOW_COPY_AND_ASSIGN(TestRLZTracker);
};
-class RlzLibTest : public RlzLibTestNoMachineState {
+class RlzLibTest : public ChromeRenderViewHostTestHarness {
protected:
void SetUp() override;
+ void TearDown() override;
void SetMainBrand(const char* brand);
void SetReactivationBrand(const char* brand);
@@ -181,13 +187,15 @@ class RlzLibTest : public RlzLibTestNoMachineState {
void ExpectReactivationRlzPingSent(bool expected);
TestRLZTracker tracker_;
+ RlzLibTestNoMachineStateHelper m_rlz_test_helper_;
#if defined(OS_POSIX)
scoped_ptr<google_brand::BrandForTesting> brand_override_;
#endif
};
void RlzLibTest::SetUp() {
- RlzLibTestNoMachineState::SetUp();
+ ChromeRenderViewHostTestHarness::SetUp();
+ m_rlz_test_helper_.SetUp();
// Make sure a non-organic brand code is set in the registry or the RLZTracker
// is pretty much a no-op.
@@ -195,6 +203,11 @@ void RlzLibTest::SetUp() {
SetReactivationBrand("");
}
+void RlzLibTest::TearDown() {
+ ChromeRenderViewHostTestHarness::TearDown();
+ m_rlz_test_helper_.TearDown();
+}
+
void RlzLibTest::SetMainBrand(const char* brand) {
#if defined(OS_WIN)
SetRegistryBrandValue(google_update::kRegRLZBrandField, brand);
@@ -250,12 +263,16 @@ void RlzLibTest::SimulateOmniboxUsage() {
}
void RlzLibTest::SimulateHomepageUsage() {
- scoped_ptr<NavigationEntry> entry(NavigationEntry::Create());
- entry->SetPageID(0);
- entry->SetTransitionType(ui::PAGE_TRANSITION_HOME_PAGE);
- tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING,
- content::NotificationService::AllSources(),
- content::Details<NavigationEntry>(entry.get()));
+ GURL home_url = GURL("https://www.google.com/");
+ GURL search_url = GURL("https://www.google.com/#q=search");
+
+ content::RenderFrameHostTester* rfht =
+ content::RenderFrameHostTester::For(main_rfh());
+
+ // Simulate a navigation to homepage first.
+ rfht->SendNavigateWithTransition(0, home_url, ui::PAGE_TRANSITION_HOME_PAGE);
+ // Then simulate a search from homepage.
+ rfht->SendNavigateWithTransition(1, search_url, ui::PAGE_TRANSITION_LINK);
}
void RlzLibTest::SimulateAppListUsage() {
@@ -825,15 +842,17 @@ TEST_F(RlzLibTest, PingUpdatesRlzCache) {
}
TEST_F(RlzLibTest, ObserveHandlesBadArgs) {
- scoped_ptr<NavigationEntry> entry(NavigationEntry::Create());
- entry->SetPageID(0);
- entry->SetTransitionType(ui::PAGE_TRANSITION_LINK);
- tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING,
+ scoped_ptr<LoadCommittedDetails> details(new LoadCommittedDetails());
+ details->entry = NavigationEntry::Create();
+ details->entry->SetPageID(0);
+ details->entry->SetTransitionType(ui::PAGE_TRANSITION_LINK);
+
+ tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_COMMITTED,
content::NotificationService::AllSources(),
content::Details<NavigationEntry>(NULL));
- tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING,
+ tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_COMMITTED,
content::NotificationService::AllSources(),
- content::Details<NavigationEntry>(entry.get()));
+ content::Details<LoadCommittedDetails>(details.get()));
}
// TODO(thakis): Reactivation doesn't exist on Mac yet.
« no previous file with comments | « chrome/browser/rlz/rlz.cc ('k') | rlz/lib/rlz_lib_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698