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

Unified Diff: chrome/browser/extensions/activity_log/counting_policy_unittest.cc

Issue 23629015: Add deletion to the activityLogPrivate API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Undoing last commit Created 7 years, 3 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: chrome/browser/extensions/activity_log/counting_policy_unittest.cc
diff --git a/chrome/browser/extensions/activity_log/counting_policy_unittest.cc b/chrome/browser/extensions/activity_log/counting_policy_unittest.cc
index d71feaf687ab09243ecfe593b58af5f6abbb8026..8a4176aab40b3038ea9b31a583e460405dce260f 100644
--- a/chrome/browser/extensions/activity_log/counting_policy_unittest.cc
+++ b/chrome/browser/extensions/activity_log/counting_policy_unittest.cc
@@ -176,6 +176,11 @@ class CountingPolicyTest : public testing::Test {
FAIL() << "Policy test timed out waiting for results";
}
+ static void RetrieveActions_FetchFilteredActions0(
+ scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
+ ASSERT_EQ(0, static_cast<int>(i->size()));
+ }
+
static void RetrieveActions_FetchFilteredActions1(
scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
ASSERT_EQ(1, static_cast<int>(i->size()));
@@ -929,4 +934,77 @@ TEST_F(CountingPolicyTest, RemoveSpecificURLs) {
policy->Close();
}
+TEST_F(CountingPolicyTest, DeleteActions) {
+ CountingPolicy* policy = new CountingPolicy(profile_.get());
+ // Disable row expiration for this test by setting a time before any actions
+ // we generate.
+ policy->set_retention_time(base::TimeDelta::FromDays(14));
+
+ // Use a mock clock to ensure that events are not recorded on the wrong day
+ // when the test is run close to local midnight. Note: Ownership is passed
+ // to the policy, but we still keep a pointer locally. The policy will take
+ // care of destruction; this is safe since the policy outlives all our
+ // accesses to the mock clock.
+ base::SimpleTestClock* mock_clock = new base::SimpleTestClock();
+ mock_clock->SetNow(base::Time::Now().LocalMidnight() +
+ base::TimeDelta::FromHours(12));
+ policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock));
+
+ // Record some actions
+ scoped_refptr<Action> action =
+ new Action("punky",
+ mock_clock->Now() - base::TimeDelta::FromMinutes(40),
+ Action::ACTION_API_CALL,
+ "brewster");
+ action->mutable_args()->AppendString("woof");
+ policy->ProcessAction(action);
+
+ action = new Action("punky",
+ mock_clock->Now() - base::TimeDelta::FromMinutes(30),
+ Action::ACTION_API_CALL,
+ "brewster");
+ action->mutable_args()->AppendString("meow");
+ policy->ProcessAction(action);
+
+ action = new Action("punky",
+ mock_clock->Now() - base::TimeDelta::FromMinutes(20),
+ Action::ACTION_API_CALL,
+ "extension.sendMessage");
+ action->mutable_args()->AppendString("not");
+ action->mutable_args()->AppendString("stripped");
+ policy->ProcessAction(action);
+
+ action =
+ new Action("punky", mock_clock->Now(), Action::ACTION_DOM_ACCESS, "lets");
+ action->mutable_args()->AppendString("vamoose");
+ action->set_page_url(GURL("http://www.google.com"));
+ policy->ProcessAction(action);
+
+ action = new Action(
+ "scoobydoo", mock_clock->Now(), Action::ACTION_DOM_ACCESS, "lets");
+ action->mutable_args()->AppendString("vamoose");
+ action->set_page_url(GURL("http://www.google.com"));
+ policy->ProcessAction(action);
+
+ CheckReadData(
+ policy,
+ "punky",
+ 0,
+ base::Bind(&CountingPolicyTest::Arguments_GetTodaysActions));
+
+ policy->DeleteDatabase();
+
+ CheckReadFilteredData(
+ policy,
+ "",
+ Action::ACTION_ANY,
+ "",
+ "",
+ "",
+ base::Bind(
+ &CountingPolicyTest::RetrieveActions_FetchFilteredActions0));
+
+ policy->Close();
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698