OLD | NEW |
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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 policy->RemoveURLs(urls); | 626 policy->RemoveURLs(urls); |
627 | 627 |
628 CheckReadData( | 628 CheckReadData( |
629 policy, | 629 policy, |
630 "punky", | 630 "punky", |
631 0, | 631 0, |
632 base::Bind(&FullStreamUIPolicyTest::SomeURLsRemoved)); | 632 base::Bind(&FullStreamUIPolicyTest::SomeURLsRemoved)); |
633 policy->Close(); | 633 policy->Close(); |
634 } | 634 } |
635 | 635 |
| 636 TEST_F(FullStreamUIPolicyTest, RemoveExtensionData) { |
| 637 FullStreamUIPolicy* policy = new FullStreamUIPolicy(profile_.get()); |
| 638 |
| 639 // Use a mock clock to ensure that events are not recorded on the wrong day |
| 640 // when the test is run close to local midnight. |
| 641 base::SimpleTestClock* mock_clock = new base::SimpleTestClock(); |
| 642 mock_clock->SetNow(base::Time::Now().LocalMidnight() + |
| 643 base::TimeDelta::FromHours(12)); |
| 644 policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock)); |
| 645 |
| 646 // Record some actions |
| 647 scoped_refptr<Action> action = new Action("deleteextensiondata", |
| 648 mock_clock->Now(), |
| 649 Action::ACTION_DOM_ACCESS, |
| 650 "lets"); |
| 651 action->mutable_args()->AppendString("vamoose"); |
| 652 action->set_page_title("Google"); |
| 653 action->set_arg_url(GURL("http://www.google.com")); |
| 654 policy->ProcessAction(action); |
| 655 policy->ProcessAction(action); |
| 656 policy->ProcessAction(action); |
| 657 |
| 658 scoped_refptr<Action> action2 = new Action("dontdelete", |
| 659 mock_clock->Now(), |
| 660 Action::ACTION_DOM_ACCESS, |
| 661 "lets"); |
| 662 action->mutable_args()->AppendString("vamoose"); |
| 663 action->set_page_title("Google"); |
| 664 action->set_arg_url(GURL("http://www.google.com")); |
| 665 policy->ProcessAction(action2); |
| 666 |
| 667 policy->Flush(); |
| 668 policy->RemoveExtensionData("deleteextensiondata"); |
| 669 |
| 670 CheckReadFilteredData( |
| 671 policy, |
| 672 "deleteextensiondata", |
| 673 Action::ACTION_ANY, |
| 674 "", |
| 675 "", |
| 676 "", |
| 677 -1, |
| 678 base::Bind( |
| 679 &FullStreamUIPolicyTest::RetrieveActions_FetchFilteredActions0)); |
| 680 |
| 681 CheckReadFilteredData( |
| 682 policy, |
| 683 "dontdelete", |
| 684 Action::ACTION_ANY, |
| 685 "", |
| 686 "", |
| 687 "", |
| 688 -1, |
| 689 base::Bind( |
| 690 &FullStreamUIPolicyTest::RetrieveActions_FetchFilteredActions1)); |
| 691 policy->Close(); |
| 692 } |
| 693 |
636 TEST_F(FullStreamUIPolicyTest, CapReturns) { | 694 TEST_F(FullStreamUIPolicyTest, CapReturns) { |
637 FullStreamUIPolicy* policy = new FullStreamUIPolicy(profile_.get()); | 695 FullStreamUIPolicy* policy = new FullStreamUIPolicy(profile_.get()); |
638 | 696 |
639 for (int i = 0; i < 305; i++) { | 697 for (int i = 0; i < 305; i++) { |
640 scoped_refptr<Action> action = | 698 scoped_refptr<Action> action = |
641 new Action("punky", | 699 new Action("punky", |
642 base::Time::Now(), | 700 base::Time::Now(), |
643 Action::ACTION_API_CALL, | 701 Action::ACTION_API_CALL, |
644 base::StringPrintf("apicall_%d", i)); | 702 base::StringPrintf("apicall_%d", i)); |
645 policy->ProcessAction(action); | 703 policy->ProcessAction(action); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 "", | 769 "", |
712 "", | 770 "", |
713 -1, | 771 -1, |
714 base::Bind( | 772 base::Bind( |
715 &FullStreamUIPolicyTest::RetrieveActions_FetchFilteredActions0)); | 773 &FullStreamUIPolicyTest::RetrieveActions_FetchFilteredActions0)); |
716 | 774 |
717 policy->Close(); | 775 policy->Close(); |
718 } | 776 } |
719 | 777 |
720 } // namespace extensions | 778 } // namespace extensions |
OLD | NEW |