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

Unified Diff: components/sync_driver/revisit/current_tab_matcher_unittest.cc

Issue 1387253004: [Sync] Creating sync_sessions component, moving revisit logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing test_support target. Created 5 years, 2 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
Index: components/sync_driver/revisit/current_tab_matcher_unittest.cc
diff --git a/components/sync_driver/revisit/current_tab_matcher_unittest.cc b/components/sync_driver/revisit/current_tab_matcher_unittest.cc
deleted file mode 100644
index 425a0e98260bce4f2a4ee9b109443cf4217ddfd7..0000000000000000000000000000000000000000
--- a/components/sync_driver/revisit/current_tab_matcher_unittest.cc
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/sync_driver/revisit/current_tab_matcher.h"
-
-#include "base/memory/scoped_ptr.h"
-#include "base/test/histogram_tester.h"
-#include "base/time/time.h"
-#include "components/sessions/core/serialized_navigation_entry.h"
-#include "components/sessions/core/serialized_navigation_entry_test_helper.h"
-#include "components/sessions/core/session_types.h"
-#include "components/sync_driver/revisit/page_equality.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "url/gurl.h"
-
-using sessions::SessionTab;
-
-namespace sync_driver {
-
-namespace {
-
-static const std::string kExampleUrl = "http://www.example.com";
-static const std::string kDifferentUrl = "http://www.different.com";
-
-sessions::SerializedNavigationEntry Entry(const std::string& url) {
- return sessions::SerializedNavigationEntryTestHelper::CreateNavigation(url,
- "");
-}
-
-scoped_ptr<SessionTab> Tab(const int index, const base::Time timestamp) {
- scoped_ptr<SessionTab> tab(new SessionTab());
- tab->current_navigation_index = index;
- tab->timestamp = timestamp;
- return tab;
-}
-
-void VerifyMatch(CurrentTabMatcher& matcher) {
- base::HistogramTester histogram_tester;
- matcher.Emit(PageVisitObserver::kTransitionPage);
- histogram_tester.ExpectUniqueSample("Sync.PageRevisitTabMatchTransition",
- PageVisitObserver::kTransitionPage, 1);
- histogram_tester.ExpectTotalCount("Sync.PageRevisitTabMatchAge", 1);
-}
-
-void VerifyMiss(CurrentTabMatcher& matcher) {
- base::HistogramTester histogram_tester;
- matcher.Emit(PageVisitObserver::kTransitionPage);
- histogram_tester.ExpectUniqueSample("Sync.PageRevisitTabMissTransition",
- PageVisitObserver::kTransitionPage, 1);
-}
-
-} // namespace
-
-TEST(CurrentTabMatcherTest, NoCheck) {
- CurrentTabMatcher matcher((PageEquality(GURL(kExampleUrl))));
- VerifyMiss(matcher);
-}
-
-TEST(CurrentTabMatcherTest, EmptyTab) {
- scoped_ptr<SessionTab> tab = Tab(0, base::Time::Now());
- CurrentTabMatcher matcher((PageEquality(GURL(kExampleUrl))));
- matcher.Check(tab.get());
- VerifyMiss(matcher);
-}
-
-TEST(CurrentTabMatcherTest, SameUrl) {
- scoped_ptr<SessionTab> tab = Tab(0, base::Time::Now());
- tab->navigations.push_back(Entry(kExampleUrl));
-
- CurrentTabMatcher matcher((PageEquality(GURL(kExampleUrl))));
- matcher.Check(tab.get());
- VerifyMatch(matcher);
-}
-
-TEST(CurrentTabMatcherTest, DifferentUrl) {
- scoped_ptr<SessionTab> tab = Tab(0, base::Time::Now());
- tab->navigations.push_back(Entry(kDifferentUrl));
-
- CurrentTabMatcher matcher((PageEquality(GURL(kExampleUrl))));
- matcher.Check(tab.get());
- VerifyMiss(matcher);
-}
-
-TEST(CurrentTabMatcherTest, DifferentIndex) {
- scoped_ptr<SessionTab> tab = Tab(0, base::Time::Now());
- tab->navigations.push_back(Entry(kDifferentUrl));
- tab->navigations.push_back(Entry(kExampleUrl));
-
- CurrentTabMatcher matcher((PageEquality(GURL(kExampleUrl))));
- matcher.Check(tab.get());
- VerifyMiss(matcher);
-}
-
-TEST(CurrentTabMatcherTest, Timestamp) {
- scoped_ptr<SessionTab> tab1 = Tab(0, base::Time::UnixEpoch());
- tab1->navigations.push_back(Entry(kExampleUrl));
-
- scoped_ptr<SessionTab> tab2 = Tab(0, base::Time::Now());
- tab2->navigations.push_back(Entry(kExampleUrl));
-
- CurrentTabMatcher matcher1((PageEquality(GURL(kExampleUrl))));
- matcher1.Check(tab1.get());
- matcher1.Check(tab2.get());
- ASSERT_EQ(tab2.get(), matcher1.most_recent_match_);
-
- // Now repeat the same test but check the tabs in the opposite order.
- CurrentTabMatcher matcher2((PageEquality(GURL(kExampleUrl))));
- matcher2.Check(tab2.get());
- matcher2.Check(tab1.get());
- ASSERT_EQ(tab2.get(), matcher2.most_recent_match_);
-}
-
-} // namespace sync_driver
« no previous file with comments | « components/sync_driver/revisit/current_tab_matcher.cc ('k') | components/sync_driver/revisit/offset_tab_matcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698