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

Unified Diff: chrome/browser/ntp_snippets/bookmark_last_visit_updater_unittest.cc

Issue 2606283003: Revert of Disable tracking of visits to bookmarks in incognito (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ntp_snippets/bookmark_last_visit_updater.cc ('k') | chrome/browser/ui/tab_helpers.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ntp_snippets/bookmark_last_visit_updater_unittest.cc
diff --git a/chrome/browser/ntp_snippets/bookmark_last_visit_updater_unittest.cc b/chrome/browser/ntp_snippets/bookmark_last_visit_updater_unittest.cc
deleted file mode 100644
index e4f943a85af615b7a53063f27cbb373ada0aa554..0000000000000000000000000000000000000000
--- a/chrome/browser/ntp_snippets/bookmark_last_visit_updater_unittest.cc
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2016 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 "chrome/browser/ntp_snippets/bookmark_last_visit_updater.h"
-
-#include <string>
-#include <vector>
-
-#include "chrome/browser/bookmarks/bookmark_model_factory.h"
-#include "chrome/test/base/testing_profile.h"
-#include "components/bookmarks/browser/bookmark_model.h"
-#include "components/bookmarks/test/bookmark_test_helpers.h"
-#include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/test/test_browser_thread_bundle.h"
-#include "content/public/test/test_web_contents_factory.h"
-#include "content/public/test/web_contents_tester.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using content::WebContents;
-using content::WebContentsTester;
-using content::TestBrowserThreadBundle;
-using content::TestWebContentsFactory;
-using testing::IsEmpty;
-using testing::Not;
-
-TEST(BookmarkLastVisitUpdaterTest, DoesNotCrashForNoBookmarkModel) {
- TestBrowserThreadBundle thread_bundle;
- TestingProfile profile;
-
- // Create a tab with the BookmarkLastVisitUpdater (with no BookmarkModel*).
- TestWebContentsFactory factory;
- WebContents* tab = factory.CreateWebContents(&profile);
- BookmarkLastVisitUpdater::MaybeCreateForWebContentsWithBookmarkModel(
- tab, /*bookmark_model=*/nullptr);
-
- // Visit a URL.
- WebContentsTester* tester = WebContentsTester::For(tab);
- tester->StartNavigation(GURL("http://foo.org/"));
-
- // The only expectation is that it does not crash.
-}
-
-TEST(BookmarkLastVisitUpdaterTest, IsTrackingVisits) {
- TestBrowserThreadBundle thread_bundle;
- TestingProfile profile;
- profile.CreateBookmarkModel(true);
- bookmarks::BookmarkModel* bookmark_model =
- BookmarkModelFactory::GetForBrowserContext(&profile);
- bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model);
-
- // Create a bookmark.
- GURL url = GURL("http://foo.org/");
- bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), 0,
- base::string16(), url);
-
- // Create a tab with the BookmarkLastVisitUpdater.
- TestWebContentsFactory factory;
- WebContents* tab = factory.CreateWebContents(&profile);
- BookmarkLastVisitUpdater::MaybeCreateForWebContentsWithBookmarkModel(
- tab, bookmark_model);
-
- // Visit the bookmarked URL.
- WebContentsTester* tester = WebContentsTester::For(tab);
- tester->StartNavigation(url);
-
- EXPECT_THAT(ntp_snippets::GetRecentlyVisitedBookmarks(
- bookmark_model, 2, base::Time::UnixEpoch(),
- /*consider_visits_from_desktop=*/true),
- Not(IsEmpty()));
-}
-
-TEST(BookmarkLastVisitUpdaterTest, IsNotTrackingIncognitoVisits) {
- TestBrowserThreadBundle thread_bundle;
- TestingProfile profile;
- profile.CreateBookmarkModel(true);
- bookmarks::BookmarkModel* bookmark_model =
- BookmarkModelFactory::GetForBrowserContext(&profile);
- bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model);
-
- // Create a couple of bookmarks.
- GURL url = GURL("http://foo.org/");
- bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), 0,
- base::string16(), url);
-
- // Create an incognito tab with the BookmarkLastVisitUpdater.
- Profile* incognito = profile.GetOffTheRecordProfile();
- TestWebContentsFactory factory;
- WebContents* tab = factory.CreateWebContents(incognito);
- BookmarkLastVisitUpdater::MaybeCreateForWebContentsWithBookmarkModel(
- tab, bookmark_model);
-
- // Visit the bookmarked URL.
- WebContentsTester* tester = WebContentsTester::For(tab);
- tester->StartNavigation(url);
-
- // The incognito visit should _not_ appear in recent bookmarks.
- EXPECT_THAT(ntp_snippets::GetRecentlyVisitedBookmarks(
- bookmark_model, 2, base::Time::UnixEpoch(),
- /*consider_visits_from_desktop=*/true),
- IsEmpty());
-}
« no previous file with comments | « chrome/browser/ntp_snippets/bookmark_last_visit_updater.cc ('k') | chrome/browser/ui/tab_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698