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

Unified Diff: chrome/browser/extensions/activity_log_unittest.cc

Issue 12918020: Removing arguments from the activity log (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed memory leak Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/activity_log.cc ('k') | chrome/browser/extensions/api_actions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/activity_log_unittest.cc
diff --git a/chrome/browser/extensions/activity_log_unittest.cc b/chrome/browser/extensions/activity_log_unittest.cc
index 42369b5587d351aa7485b720367784cbd1bc69df..f678d7b481dca542d32fd591fa16785f2fffa8f0 100644
--- a/chrome/browser/extensions/activity_log_unittest.cc
+++ b/chrome/browser/extensions/activity_log_unittest.cc
@@ -50,6 +50,23 @@ class ActivityLogTest : public ChromeRenderViewHostTestHarness {
ASSERT_EQ(2, static_cast<int>(i->size()));
}
+ static void Arguments_Missing(
+ scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
+ scoped_refptr<Action> last = i->front();
+ std::string noargs = "ID: odlameecjipmbmbejkplpemijjgpljce, CATEGORY: "
+ "CALL, VERB: UNKNOWN_VERB, TARGET: TABS, API: tabs.testMethod, ARGS: ";
+ ASSERT_EQ(noargs, last->PrettyPrintForDebug());
+ }
+
+ static void Arguments_Present(
+ scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
+ scoped_refptr<Action> last = i->front();
+ std::string args = "ID: odlameecjipmbmbejkplpemijjgpljce, CATEGORY: "
+ "CALL, VERB: UNKNOWN_VERB, TARGET: UNKNOWN_TARGET, API: "
+ "extension.connect, ARGS: \"hello\", \"world\"";
+ ASSERT_EQ(args, last->PrettyPrintForDebug());
+ }
+
protected:
ExtensionService* extension_service_;
Profile* profile_;
@@ -112,5 +129,55 @@ TEST_F(ActivityLogTest, LogAndFetchActions) {
base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions));
}
+TEST_F(ActivityLogTest, LogWithoutArguments) {
+ ActivityLog* activity_log = ActivityLog::GetInstance(profile_);
+ scoped_refptr<const Extension> extension =
+ ExtensionBuilder()
+ .SetManifest(DictionaryBuilder()
+ .Set("name", "Test extension")
+ .Set("version", "1.0.0")
+ .Set("manifest_version", 2))
+ .Build();
+ extension_service_->AddExtension(extension);
+ ASSERT_TRUE(ActivityLog::IsLogEnabled());
+
+ scoped_ptr<ListValue> args(new ListValue());
+ args->Set(0, new base::StringValue("hello"));
+ args->Set(1, new base::StringValue("world"));
+ activity_log->LogAPIAction(extension,
+ std::string("tabs.testMethod"),
+ args.get(),
+ "");
+ activity_log->GetActions(
+ extension->id(),
+ 0,
+ base::Bind(ActivityLogTest::Arguments_Missing));
+}
+
+TEST_F(ActivityLogTest, LogWithArguments) {
+ ActivityLog* activity_log = ActivityLog::GetInstance(profile_);
+ scoped_refptr<const Extension> extension =
+ ExtensionBuilder()
+ .SetManifest(DictionaryBuilder()
+ .Set("name", "Test extension")
+ .Set("version", "1.0.0")
+ .Set("manifest_version", 2))
+ .Build();
+ extension_service_->AddExtension(extension);
+ ASSERT_TRUE(ActivityLog::IsLogEnabled());
+
+ scoped_ptr<ListValue> args(new ListValue());
+ args->Set(0, new base::StringValue("hello"));
+ args->Set(1, new base::StringValue("world"));
+ activity_log->LogAPIAction(extension,
+ std::string("extension.connect"),
+ args.get(),
+ "");
+ activity_log->GetActions(
+ extension->id(),
+ 0,
+ base::Bind(ActivityLogTest::Arguments_Present));
+}
+
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/activity_log.cc ('k') | chrome/browser/extensions/api_actions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698