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

Side by Side Diff: chrome/browser/extensions/activity_log/counting_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 | « no previous file | chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc » ('j') | 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/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 } 297 }
298 298
299 // A helper function initializes the policy with a number of actions, calls 299 // A helper function initializes the policy with a number of actions, calls
300 // RemoveActions on a policy object and then checks the result of the 300 // RemoveActions on a policy object and then checks the result of the
301 // deletion. 301 // deletion.
302 void CheckRemoveActions( 302 void CheckRemoveActions(
303 ActivityLogDatabasePolicy* policy, 303 ActivityLogDatabasePolicy* policy,
304 const std::vector<int64>& action_ids, 304 const std::vector<int64>& action_ids,
305 const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker) { 305 const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker) {
306 306
307 // Use a mock clock to ensure that events are not recorded on the wrong day
308 // when the test is run close to local midnight.
309 base::SimpleTestClock* mock_clock = new base::SimpleTestClock();
310 mock_clock->SetNow(base::Time::Now().LocalMidnight() +
311 base::TimeDelta::FromHours(12));
312 policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock));
313
307 // Record some actions 314 // Record some actions
308 scoped_refptr<Action> action = new Action( 315 scoped_refptr<Action> action =
309 "punky1", base::Time::Now(), Action::ACTION_DOM_ACCESS, "lets1"); 316 new Action("punky1",
317 mock_clock->Now() - base::TimeDelta::FromMinutes(40),
318 Action::ACTION_DOM_ACCESS,
319 "lets1");
310 action->mutable_args()->AppendString("vamoose1"); 320 action->mutable_args()->AppendString("vamoose1");
311 action->set_page_url(GURL("http://www.google1.com")); 321 action->set_page_url(GURL("http://www.google1.com"));
312 action->set_page_title("Google1"); 322 action->set_page_title("Google1");
313 action->set_arg_url(GURL("http://www.args-url1.com")); 323 action->set_arg_url(GURL("http://www.args-url1.com"));
314 policy->ProcessAction(action); 324 policy->ProcessAction(action);
315 // Record the same action twice, so there are multiple entries in the 325 // Record the same action twice, so there are multiple entries in the
316 // database. 326 // database.
317 policy->ProcessAction(action); 327 policy->ProcessAction(action);
318 328
319 action = new Action( 329 action = new Action("punky2",
320 "punky2", base::Time::Now(), Action::ACTION_API_CALL, "lets2"); 330 mock_clock->Now() - base::TimeDelta::FromMinutes(30),
331 Action::ACTION_API_CALL,
332 "lets2");
321 action->mutable_args()->AppendString("vamoose2"); 333 action->mutable_args()->AppendString("vamoose2");
322 action->set_page_url(GURL("http://www.google2.com")); 334 action->set_page_url(GURL("http://www.google2.com"));
323 action->set_page_title("Google2"); 335 action->set_page_title("Google2");
324 action->set_arg_url(GURL("http://www.args-url2.com")); 336 action->set_arg_url(GURL("http://www.args-url2.com"));
325 policy->ProcessAction(action); 337 policy->ProcessAction(action);
326 // Record the same action twice, so there are multiple entries in the 338 // Record the same action twice, so there are multiple entries in the
327 // database. 339 // database.
328 policy->ProcessAction(action); 340 policy->ProcessAction(action);
329 341
330 // Submit a request to delete actions. 342 // Submit a request to delete actions.
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 1305
1294 action_ids.push_back(2); 1306 action_ids.push_back(2);
1295 CheckRemoveActions( 1307 CheckRemoveActions(
1296 policy, action_ids, base::Bind(&CountingPolicyTest::Action2Deleted)); 1308 policy, action_ids, base::Bind(&CountingPolicyTest::Action2Deleted));
1297 action_ids.clear(); 1309 action_ids.clear();
1298 1310
1299 policy->Close(); 1311 policy->Close();
1300 } 1312 }
1301 1313
1302 } // namespace extensions 1314 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698