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

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

Issue 23629015: Add deletion to the activityLogPrivate API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up CountingPolicy::DoDeleteDatabase 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 unified diff | Download patch | Annotate | Revision Log
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/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "base/test/simple_test_clock.h" 10 #include "base/test/simple_test_clock.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 static void TimeoutCallback() { 139 static void TimeoutCallback() {
140 base::MessageLoop::current()->QuitWhenIdle(); 140 base::MessageLoop::current()->QuitWhenIdle();
141 FAIL() << "Policy test timed out waiting for results"; 141 FAIL() << "Policy test timed out waiting for results";
142 } 142 }
143 143
144 static void RetrieveActions_LogAndFetchActions( 144 static void RetrieveActions_LogAndFetchActions(
145 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { 145 scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
146 ASSERT_EQ(2, static_cast<int>(i->size())); 146 ASSERT_EQ(2, static_cast<int>(i->size()));
147 } 147 }
148 148
149 static void RetrieveActions_FetchFilteredActions0(
150 scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
151 ASSERT_EQ(0, static_cast<int>(i->size()));
152 }
153
149 static void RetrieveActions_FetchFilteredActions1( 154 static void RetrieveActions_FetchFilteredActions1(
150 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { 155 scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
151 ASSERT_EQ(1, static_cast<int>(i->size())); 156 ASSERT_EQ(1, static_cast<int>(i->size()));
152 } 157 }
153 158
154 static void RetrieveActions_FetchFilteredActions2( 159 static void RetrieveActions_FetchFilteredActions2(
155 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { 160 scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
156 ASSERT_EQ(2, static_cast<int>(i->size())); 161 ASSERT_EQ(2, static_cast<int>(i->size()));
157 } 162 }
158 163
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 policy->RemoveURLs(urls); 640 policy->RemoveURLs(urls);
636 641
637 CheckReadData( 642 CheckReadData(
638 policy, 643 policy,
639 "punky", 644 "punky",
640 0, 645 0,
641 base::Bind(&FullStreamUIPolicyTest::SomeURLsRemoved)); 646 base::Bind(&FullStreamUIPolicyTest::SomeURLsRemoved));
642 policy->Close(); 647 policy->Close();
643 } 648 }
644 649
650 TEST_F(FullStreamUIPolicyTest, DeleteActions) {
651 ActivityLogPolicy* policy = new FullStreamUIPolicy(profile_.get());
652 scoped_refptr<const Extension> extension =
653 ExtensionBuilder()
654 .SetManifest(DictionaryBuilder()
655 .Set("name", "Test extension")
656 .Set("version", "1.0.0")
657 .Set("manifest_version", 2))
658 .Build();
659 extension_service_->AddExtension(extension.get());
660 GURL gurl("http://www.google.com");
661
662 // Write some API calls.
663 scoped_refptr<Action> action_api = new Action(extension->id(),
664 base::Time::Now(),
665 Action::ACTION_API_CALL,
666 "tabs.testMethod");
667 action_api->set_args(make_scoped_ptr(new base::ListValue()));
668 policy->ProcessAction(action_api);
669
670 scoped_refptr<Action> action_dom = new Action(extension->id(),
671 base::Time::Now(),
672 Action::ACTION_DOM_ACCESS,
673 "document.write");
674 action_dom->set_args(make_scoped_ptr(new base::ListValue()));
675 action_dom->set_page_url(gurl);
676 policy->ProcessAction(action_dom);
677
678 CheckReadData(
679 policy,
680 extension->id(),
681 0,
682 base::Bind(&FullStreamUIPolicyTest::RetrieveActions_LogAndFetchActions));
683
684 // Now delete them.
685 policy->DeleteDatabase();
686
687 CheckReadFilteredData(
688 policy,
689 "",
690 Action::ACTION_ANY,
691 "",
692 "",
693 "",
694 base::Bind(
695 &FullStreamUIPolicyTest::RetrieveActions_FetchFilteredActions0));
696
697 policy->Close();
698 }
699
645 } // namespace extensions 700 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698