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

Side by Side Diff: chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc

Issue 166233006: Fix for CountingPolicyTest.RemoveActions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added fullstream_ui_policy_unittest Created 6 years, 10 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/extensions/activity_log/counting_policy_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/cancelable_callback.h" 5 #include "base/cancelable_callback.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 222 }
223 223
224 // A helper function initializes the policy with a number of actions, calls 224 // A helper function initializes the policy with a number of actions, calls
225 // RemoveActions on a policy object and then checks the result of the 225 // RemoveActions on a policy object and then checks the result of the
226 // deletion. 226 // deletion.
227 void CheckRemoveActions( 227 void CheckRemoveActions(
228 ActivityLogDatabasePolicy* policy, 228 ActivityLogDatabasePolicy* policy,
229 const std::vector<int64>& action_ids, 229 const std::vector<int64>& action_ids,
230 const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker) { 230 const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker) {
231 231
232 // Use a mock clock to ensure that events are not recorded on the wrong day
233 // when the test is run close to local midnight.
234 base::SimpleTestClock* mock_clock = new base::SimpleTestClock();
235 mock_clock->SetNow(base::Time::Now().LocalMidnight() +
236 base::TimeDelta::FromHours(12));
237 policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock));
238
232 // Record some actions 239 // Record some actions
233 scoped_refptr<Action> action = new Action( 240 scoped_refptr<Action> action =
234 "punky1", base::Time::Now(), Action::ACTION_DOM_ACCESS, "lets1"); 241 new Action("punky1",
242 mock_clock->Now() - base::TimeDelta::FromMinutes(40),
243 Action::ACTION_DOM_ACCESS,
244 "lets1");
235 action->mutable_args()->AppendString("vamoose1"); 245 action->mutable_args()->AppendString("vamoose1");
236 action->set_page_url(GURL("http://www.google1.com")); 246 action->set_page_url(GURL("http://www.google1.com"));
237 action->set_page_title("Google1"); 247 action->set_page_title("Google1");
238 action->set_arg_url(GURL("http://www.args-url1.com")); 248 action->set_arg_url(GURL("http://www.args-url1.com"));
239 policy->ProcessAction(action); 249 policy->ProcessAction(action);
240 // Record the same action twice, so there are multiple entries in the 250 // Record the same action twice, so there are multiple entries in the
241 // database. 251 // database.
242 policy->ProcessAction(action); 252 policy->ProcessAction(action);
243 253
244 action = new Action( 254 action = new Action("punky2",
245 "punky2", base::Time::Now(), Action::ACTION_API_CALL, "lets2"); 255 mock_clock->Now() - base::TimeDelta::FromMinutes(30),
256 Action::ACTION_API_CALL,
257 "lets2");
246 action->mutable_args()->AppendString("vamoose2"); 258 action->mutable_args()->AppendString("vamoose2");
247 action->set_page_url(GURL("http://www.google2.com")); 259 action->set_page_url(GURL("http://www.google2.com"));
248 action->set_page_title("Google2"); 260 action->set_page_title("Google2");
249 action->set_arg_url(GURL("http://www.args-url2.com")); 261 action->set_arg_url(GURL("http://www.args-url2.com"));
250 policy->ProcessAction(action); 262 policy->ProcessAction(action);
251 // Record the same action twice, so there are multiple entries in the 263 // Record the same action twice, so there are multiple entries in the
252 // database. 264 // database.
253 policy->ProcessAction(action); 265 policy->ProcessAction(action);
254 266
255 // Submit a request to delete actions. 267 // Submit a request to delete actions.
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 action_ids.push_back(3); 983 action_ids.push_back(3);
972 action_ids.push_back(4); 984 action_ids.push_back(4);
973 CheckRemoveActions( 985 CheckRemoveActions(
974 policy, action_ids, base::Bind(&FullStreamUIPolicyTest::Action2Deleted)); 986 policy, action_ids, base::Bind(&FullStreamUIPolicyTest::Action2Deleted));
975 action_ids.clear(); 987 action_ids.clear();
976 988
977 policy->Close(); 989 policy->Close();
978 } 990 }
979 991
980 } // namespace extensions 992 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/activity_log/counting_policy_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698