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

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

Issue 19234003: Extension activity log database refactoring (step 2) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Unit test fixes Created 7 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.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 "chrome/browser/extensions/activity_log/activity_log.h" 10 #include "chrome/browser/extensions/activity_log/activity_log.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 ASSERT_EQ(2, static_cast<int>(i->size())); 77 ASSERT_EQ(2, static_cast<int>(i->size()));
78 } 78 }
79 79
80 static void RetrieveActions_LogAndFetchPathActions( 80 static void RetrieveActions_LogAndFetchPathActions(
81 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { 81 scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
82 std::string args; 82 std::string args;
83 ASSERT_EQ(1U, i->size()); 83 ASSERT_EQ(1U, i->size());
84 scoped_refptr<Action> last = i->front(); 84 scoped_refptr<Action> last = i->front();
85 if (CommandLine::ForCurrentProcess()->HasSwitch( 85 if (CommandLine::ForCurrentProcess()->HasSwitch(
86 switches::kEnableExtensionActivityLogTesting)) 86 switches::kEnableExtensionActivityLogTesting))
87 args = "Injected scripts () onto " 87 args = "ID=abc CATEGORY=content_script API=document.write ARGS=[\"\"] "
88 "http://www.google.com/foo?bar extra"; 88 "PAGE_URL=http://www.google.com/foo?bar OTHER={}";
89 else 89 else
90 args = "Injected scripts () onto " 90 args = "ID=abc CATEGORY=content_script API=document.write ARGS=[\"\"] "
91 "http://www.google.com/foo extra"; 91 "PAGE_URL=http://www.google.com/foo OTHER={}";
92 ASSERT_EQ(args, last->PrintForDebug()); 92 ASSERT_EQ(args, last->PrintForDebug());
93 } 93 }
94 94
95 static void Arguments_Missing( 95 static void Arguments_Missing(
96 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { 96 scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
97 scoped_refptr<Action> last = i->front(); 97 scoped_refptr<Action> last = i->front();
98 std::string id(kExtensionId); 98 std::string id(kExtensionId);
99 std::string noargs = "ID: " + id + ", CATEGORY: " 99 std::string noargs =
100 "call, API: tabs.testMethod, ARGS: "; 100 "ID=" + id + " CATEGORY=api_call API=tabs.testMethod ARGS=[] OTHER={}";
101 ASSERT_EQ(noargs, last->PrintForDebug()); 101 ASSERT_EQ(noargs, last->PrintForDebug());
102 } 102 }
103 103
104 static void Arguments_Present( 104 static void Arguments_Present(
105 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { 105 scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
106 scoped_refptr<Action> last = i->front(); 106 scoped_refptr<Action> last = i->front();
107 std::string id(kExtensionId); 107 std::string id(kExtensionId);
108 std::string args = "ID: " + id + ", CATEGORY: " 108 std::string args = "ID=" + id + " CATEGORY=api_call API=extension.connect "
109 "call, API: extension.connect, ARGS: \"hello\", \"world\""; 109 "ARGS=[\"hello\",\"world\"] OTHER={}";
110 ASSERT_EQ(args, last->PrintForDebug()); 110 ASSERT_EQ(args, last->PrintForDebug());
111 } 111 }
112 112
113 void SetPolicy(bool log_arguments) { 113 void SetPolicy(bool log_arguments) {
114 ActivityLog* activity_log = ActivityLog::GetInstance(profile()); 114 ActivityLog* activity_log = ActivityLog::GetInstance(profile());
115 if (log_arguments) 115 if (log_arguments)
116 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM); 116 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM);
117 else 117 else
118 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_NOARGS); 118 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_NOARGS);
119 } 119 }
120 120
121 static void Arguments_Prerender( 121 static void Arguments_Prerender(
122 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { 122 scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
123 ASSERT_EQ(1U, i->size()); 123 ASSERT_EQ(1U, i->size());
124 scoped_refptr<Action> last = i->front(); 124 scoped_refptr<Action> last = i->front();
125 std::string args = "Injected scripts (\"script \") " 125 std::string args =
126 "onto http://www.google.com/ (prerender)"; 126 "ID=odlameecjipmbmbejkplpemijjgpljce CATEGORY=content_script API= "
127 "ARGS=[\"\\\"script \\\"\"] PAGE_URL=http://www.google.com/ OTHER={}";
127 ASSERT_EQ(args, last->PrintForDebug()); 128 ASSERT_EQ(args, last->PrintForDebug());
128 } 129 }
129 130
130 ExtensionService* extension_service_; 131 ExtensionService* extension_service_;
131 // Used to preserve a copy of the original command line. 132 // Used to preserve a copy of the original command line.
132 // The test framework will do this itself as well. However, by then, 133 // The test framework will do this itself as well. However, by then,
133 // it is too late to call ActivityLog::RecomputeLoggingIsEnabled() in 134 // it is too late to call ActivityLog::RecomputeLoggingIsEnabled() in
134 // TearDown(). 135 // TearDown().
135 CommandLine saved_cmdline_; 136 CommandLine saved_cmdline_;
136 137
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 OnScriptsExecuted(contents, executing_scripts, 0, url); 259 OnScriptsExecuted(contents, executing_scripts, 0, url);
259 260
260 activity_log->GetActions( 261 activity_log->GetActions(
261 extension->id(), 0, base::Bind(ActivityLogTest::Arguments_Prerender)); 262 extension->id(), 0, base::Bind(ActivityLogTest::Arguments_Prerender));
262 263
263 prerender_manager->CancelAllPrerenders(); 264 prerender_manager->CancelAllPrerenders();
264 } 265 }
265 266
266 } // namespace extensions 267 } // namespace extensions
267 268
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698