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

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: 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 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/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 static void TimeoutCallback() { 140 static void TimeoutCallback() {
141 base::MessageLoop::current()->QuitWhenIdle(); 141 base::MessageLoop::current()->QuitWhenIdle();
142 FAIL() << "Policy test timed out waiting for results"; 142 FAIL() << "Policy test timed out waiting for results";
143 } 143 }
144 144
145 static void RetrieveActions_LogAndFetchActions( 145 static void RetrieveActions_LogAndFetchActions(
146 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { 146 scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
147 ASSERT_EQ(2, static_cast<int>(i->size())); 147 ASSERT_EQ(2, static_cast<int>(i->size()));
148 } 148 }
149 149
150 static void RetrieveActions_FetchFilteredActions0(
151 scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
152 ASSERT_EQ(0, static_cast<int>(i->size()));
153 }
154
150 static void RetrieveActions_FetchFilteredActions1( 155 static void RetrieveActions_FetchFilteredActions1(
151 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { 156 scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
152 ASSERT_EQ(1, static_cast<int>(i->size())); 157 ASSERT_EQ(1, static_cast<int>(i->size()));
153 } 158 }
154 159
155 static void RetrieveActions_FetchFilteredActions2( 160 static void RetrieveActions_FetchFilteredActions2(
156 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { 161 scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
157 ASSERT_EQ(2, static_cast<int>(i->size())); 162 ASSERT_EQ(2, static_cast<int>(i->size()));
158 } 163 }
159 164
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 "punky", 671 "punky",
667 Action::ACTION_ANY, 672 Action::ACTION_ANY,
668 "", 673 "",
669 "", 674 "",
670 "", 675 "",
671 base::Bind( 676 base::Bind(
672 &FullStreamUIPolicyTest::RetrieveActions_FetchFilteredActions300)); 677 &FullStreamUIPolicyTest::RetrieveActions_FetchFilteredActions300));
673 policy->Close(); 678 policy->Close();
674 } 679 }
675 680
681 TEST_F(FullStreamUIPolicyTest, DeleteActions) {
682 ActivityLogPolicy* policy = new FullStreamUIPolicy(profile_.get());
683 scoped_refptr<const Extension> extension =
684 ExtensionBuilder()
685 .SetManifest(DictionaryBuilder()
686 .Set("name", "Test extension")
687 .Set("version", "1.0.0")
688 .Set("manifest_version", 2))
689 .Build();
690 extension_service_->AddExtension(extension.get());
691 GURL gurl("http://www.google.com");
692
693 // Write some API calls.
694 scoped_refptr<Action> action_api = new Action(extension->id(),
695 base::Time::Now(),
696 Action::ACTION_API_CALL,
697 "tabs.testMethod");
698 action_api->set_args(make_scoped_ptr(new base::ListValue()));
699 policy->ProcessAction(action_api);
700
701 scoped_refptr<Action> action_dom = new Action(extension->id(),
702 base::Time::Now(),
703 Action::ACTION_DOM_ACCESS,
704 "document.write");
705 action_dom->set_args(make_scoped_ptr(new base::ListValue()));
706 action_dom->set_page_url(gurl);
707 policy->ProcessAction(action_dom);
708
709 CheckReadData(
710 policy,
711 extension->id(),
712 0,
713 base::Bind(&FullStreamUIPolicyTest::RetrieveActions_LogAndFetchActions));
714
715 // Now delete them.
716 policy->DeleteDatabase();
717
718 CheckReadFilteredData(
719 policy,
720 "",
721 Action::ACTION_ANY,
722 "",
723 "",
724 "",
725 base::Bind(
726 &FullStreamUIPolicyTest::RetrieveActions_FetchFilteredActions0));
727
728 policy->Close();
729 }
730
676 } // namespace extensions 731 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698