Index: chrome/browser/history/history_backend_unittest.cc |
diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc |
index b3508a5c36e3a655948ca3991ca5089906b96082..2253ea01048a649a72657bd029cf160c794b4dda 100644 |
--- a/chrome/browser/history/history_backend_unittest.cc |
+++ b/chrome/browser/history/history_backend_unittest.cc |
@@ -32,7 +32,6 @@ |
#include "chrome/browser/history/visit_filter.h" |
#include "chrome/common/chrome_constants.h" |
#include "chrome/common/chrome_paths.h" |
-#include "chrome/common/chrome_switches.h" |
#include "chrome/common/importer/imported_favicon_usage.h" |
#include "chrome/test/base/testing_profile.h" |
#include "content/public/browser/notification_details.h" |
@@ -42,7 +41,6 @@ |
#include "url/gurl.h" |
using base::Time; |
-using base::TimeDelta; |
// This file only tests functionality where it is most convenient to call the |
// backend directly. Most of the history backend functions are tested by the |
@@ -360,6 +358,11 @@ class HistoryBackendTest : public testing::Test { |
BookmarkModel bookmark_model_; |
protected: |
+ bool loaded_; |
+ |
+ private: |
+ friend class HistoryBackendTestDelegate; |
+ |
// testing::Test |
virtual void SetUp() { |
if (!base::CreateNewTempDirectory(FILE_PATH_LITERAL("BackendTest"), |
@@ -372,11 +375,6 @@ class HistoryBackendTest : public testing::Test { |
backend_->Init(std::string(), false); |
} |
- bool loaded_; |
- |
- private: |
- friend class HistoryBackendTestDelegate; |
- |
virtual void TearDown() { |
if (backend_.get()) |
backend_->Closing(); |
@@ -2800,92 +2798,6 @@ TEST_F(HistoryBackendTest, DeleteMatchingUrlsForKeyword) { |
EXPECT_FALSE(backend_->db()->GetKeywordSearchTermRow(url3_id, NULL)); |
} |
-class HistoryBackendSegmentDurationTest : public HistoryBackendTest { |
- public: |
- HistoryBackendSegmentDurationTest() {} |
- |
- virtual void SetUp() { |
- CommandLine::ForCurrentProcess()->AppendSwitch( |
- switches::kTrackActiveVisitTime); |
- HistoryBackendTest::SetUp(); |
- } |
- |
- private: |
- DISALLOW_COPY_AND_ASSIGN(HistoryBackendSegmentDurationTest); |
-}; |
- |
-// Assertions around segment durations. |
-TEST_F(HistoryBackendSegmentDurationTest, SegmentDuration) { |
- const GURL url1("http://www.google.com"); |
- const GURL url2("http://www.foo.com/m"); |
- const std::string segment1(VisitSegmentDatabase::ComputeSegmentName(url1)); |
- const std::string segment2(VisitSegmentDatabase::ComputeSegmentName(url2)); |
- |
- Time segment_time(VisitSegmentDatabase::SegmentTime(Time::Now())); |
- URLRow url_info1(url1); |
- url_info1.set_visit_count(0); |
- url_info1.set_typed_count(0); |
- url_info1.set_last_visit(segment_time); |
- url_info1.set_hidden(false); |
- const URLID url1_id = backend_->db()->AddURL(url_info1); |
- EXPECT_NE(0, url1_id); |
- |
- URLRow url_info2(url2); |
- url_info2.set_visit_count(0); |
- url_info2.set_typed_count(0); |
- url_info2.set_last_visit(Time()); |
- url_info2.set_hidden(false); |
- const URLID url2_id = backend_->db()->AddURL(url_info2); |
- EXPECT_NE(0, url2_id); |
- EXPECT_NE(url1_id, url2_id); |
- |
- // Should not have any segments for the urls. |
- EXPECT_EQ(0, backend_->db()->GetSegmentNamed(segment1)); |
- EXPECT_EQ(0, backend_->db()->GetSegmentNamed(segment2)); |
- |
- // Update the duration, which should implicitly create the segments. |
- const TimeDelta segment1_time_delta(TimeDelta::FromHours(1)); |
- const TimeDelta segment2_time_delta(TimeDelta::FromHours(2)); |
- backend_->IncreaseSegmentDuration(url1, segment_time, segment1_time_delta); |
- backend_->IncreaseSegmentDuration(url2, segment_time, segment2_time_delta); |
- |
- // Get the ids of the segments that were created. |
- const SegmentID segment1_id = backend_->db()->GetSegmentNamed(segment1); |
- EXPECT_NE(0, segment1_id); |
- const SegmentID segment2_id = backend_->db()->GetSegmentNamed(segment2); |
- EXPECT_NE(0, segment2_id); |
- EXPECT_NE(segment1_id, segment2_id); |
- |
- // Make sure the values made it to the db. |
- SegmentDurationID segment1_duration_id; |
- TimeDelta fetched_delta; |
- EXPECT_TRUE(backend_->db()->GetSegmentDuration( |
- segment1_id, segment_time, &segment1_duration_id, |
- &fetched_delta)); |
- EXPECT_NE(0, segment1_duration_id); |
- EXPECT_EQ(segment1_time_delta.InHours(), fetched_delta.InHours()); |
- |
- SegmentDurationID segment2_duration_id; |
- EXPECT_TRUE(backend_->db()->GetSegmentDuration( |
- segment2_id, segment_time, &segment2_duration_id, |
- &fetched_delta)); |
- EXPECT_NE(0, segment2_duration_id); |
- EXPECT_NE(segment1_duration_id, segment2_duration_id); |
- EXPECT_EQ(segment2_time_delta.InHours(), fetched_delta.InHours()); |
- |
- // Query by duration. |url2| should be first as it has a longer view time. |
- ScopedVector<PageUsageData> data; |
- backend_->db()->QuerySegmentDuration(segment_time, 10, &data.get()); |
- ASSERT_EQ(2u, data.size()); |
- EXPECT_EQ(url2.spec(), data[0]->GetURL().spec()); |
- EXPECT_EQ(url2_id, data[0]->GetID()); |
- EXPECT_EQ(segment2_time_delta.InHours(), data[0]->duration().InHours()); |
- |
- EXPECT_EQ(url1.spec(), data[1]->GetURL().spec()); |
- EXPECT_EQ(url1_id, data[1]->GetID()); |
- EXPECT_EQ(segment1_time_delta.InHours(), data[1]->duration().InHours()); |
-} |
- |
// Simple test that removes a bookmark. This test exercises the code paths in |
// History that block till bookmark bar model is loaded. |
TEST_F(HistoryBackendTest, RemoveNotification) { |