OLD | NEW |
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_; | 181 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_; |
182 #endif | 182 #endif |
183 }; | 183 }; |
184 | 184 |
185 TEST_F(ActivityLogTest, Enabled) { | 185 TEST_F(ActivityLogTest, Enabled) { |
186 ASSERT_TRUE(ActivityLog::IsLogEnabledOnAnyProfile()); | 186 ASSERT_TRUE(ActivityLog::IsLogEnabledOnAnyProfile()); |
187 } | 187 } |
188 | 188 |
189 TEST_F(ActivityLogTest, Construct) { | 189 TEST_F(ActivityLogTest, Construct) { |
190 ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get()); | 190 ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get()); |
191 scoped_ptr<ListValue> args(new ListValue()); | 191 scoped_ptr<base::ListValue> args(new base::ListValue()); |
192 ASSERT_TRUE(activity_log->IsLogEnabled()); | 192 ASSERT_TRUE(activity_log->IsLogEnabled()); |
193 activity_log->LogAPIAction( | 193 activity_log->LogAPIAction( |
194 kExtensionId, std::string("tabs.testMethod"), args.get(), std::string()); | 194 kExtensionId, std::string("tabs.testMethod"), args.get(), std::string()); |
195 } | 195 } |
196 | 196 |
197 TEST_F(ActivityLogTest, LogAndFetchActions) { | 197 TEST_F(ActivityLogTest, LogAndFetchActions) { |
198 ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get()); | 198 ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get()); |
199 scoped_ptr<ListValue> args(new ListValue()); | 199 scoped_ptr<base::ListValue> args(new base::ListValue()); |
200 ASSERT_TRUE(activity_log->IsLogEnabled()); | 200 ASSERT_TRUE(activity_log->IsLogEnabled()); |
201 | 201 |
202 // Write some API calls | 202 // Write some API calls |
203 activity_log->LogAPIAction( | 203 activity_log->LogAPIAction( |
204 kExtensionId, std::string("tabs.testMethod"), args.get(), std::string()); | 204 kExtensionId, std::string("tabs.testMethod"), args.get(), std::string()); |
205 activity_log->LogDOMAction(kExtensionId, | 205 activity_log->LogDOMAction(kExtensionId, |
206 GURL("http://www.google.com"), | 206 GURL("http://www.google.com"), |
207 string16(), | 207 string16(), |
208 std::string("document.write"), | 208 std::string("document.write"), |
209 args.get(), | 209 args.get(), |
210 DomActionType::METHOD, | 210 DomActionType::METHOD, |
211 std::string("extra")); | 211 std::string("extra")); |
212 activity_log->GetActions( | 212 activity_log->GetActions( |
213 kExtensionId, | 213 kExtensionId, |
214 0, | 214 0, |
215 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions)); | 215 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions)); |
216 } | 216 } |
217 | 217 |
218 TEST_F(ActivityLogTest, LogAndFetchPathActions) { | 218 TEST_F(ActivityLogTest, LogAndFetchPathActions) { |
219 ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get()); | 219 ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get()); |
220 scoped_ptr<ListValue> args(new ListValue()); | 220 scoped_ptr<base::ListValue> args(new base::ListValue()); |
221 ASSERT_TRUE(activity_log->IsLogEnabled()); | 221 ASSERT_TRUE(activity_log->IsLogEnabled()); |
222 | 222 |
223 activity_log->LogDOMAction(kExtensionId, | 223 activity_log->LogDOMAction(kExtensionId, |
224 GURL("http://www.google.com/foo?bar"), | 224 GURL("http://www.google.com/foo?bar"), |
225 string16(), | 225 string16(), |
226 std::string("document.write"), | 226 std::string("document.write"), |
227 args.get(), | 227 args.get(), |
228 DomActionType::INSERTED, | 228 DomActionType::INSERTED, |
229 std::string("extra")); | 229 std::string("extra")); |
230 activity_log->GetActions( | 230 activity_log->GetActions( |
231 kExtensionId, | 231 kExtensionId, |
232 0, | 232 0, |
233 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchPathActions)); | 233 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchPathActions)); |
234 } | 234 } |
235 | 235 |
236 TEST_F(ActivityLogTest, LogWithoutArguments) { | 236 TEST_F(ActivityLogTest, LogWithoutArguments) { |
237 ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get()); | 237 ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get()); |
238 activity_log->SetArgumentLoggingForTesting(false); | 238 activity_log->SetArgumentLoggingForTesting(false); |
239 ASSERT_TRUE(activity_log->IsLogEnabled()); | 239 ASSERT_TRUE(activity_log->IsLogEnabled()); |
240 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_NOARGS); | 240 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_NOARGS); |
241 scoped_ptr<ListValue> args(new ListValue()); | 241 scoped_ptr<base::ListValue> args(new base::ListValue()); |
242 args->Set(0, new base::StringValue("hello")); | 242 args->Set(0, new base::StringValue("hello")); |
243 args->Set(1, new base::StringValue("world")); | 243 args->Set(1, new base::StringValue("world")); |
244 activity_log->LogAPIAction( | 244 activity_log->LogAPIAction( |
245 kExtensionId, std::string("tabs.testMethod"), args.get(), std::string()); | 245 kExtensionId, std::string("tabs.testMethod"), args.get(), std::string()); |
246 activity_log->GetActions( | 246 activity_log->GetActions( |
247 kExtensionId, 0, base::Bind(ActivityLogTest::Arguments_Missing)); | 247 kExtensionId, 0, base::Bind(ActivityLogTest::Arguments_Missing)); |
248 } | 248 } |
249 | 249 |
250 TEST_F(ActivityLogTest, LogWithArguments) { | 250 TEST_F(ActivityLogTest, LogWithArguments) { |
251 ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get()); | 251 ActivityLog* activity_log = ActivityLog::GetInstance(profile_.get()); |
252 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM); | 252 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM); |
253 ASSERT_TRUE(activity_log->IsLogEnabled()); | 253 ASSERT_TRUE(activity_log->IsLogEnabled()); |
254 | 254 |
255 scoped_ptr<ListValue> args(new ListValue()); | 255 scoped_ptr<base::ListValue> args(new base::ListValue()); |
256 args->Set(0, new base::StringValue("hello")); | 256 args->Set(0, new base::StringValue("hello")); |
257 args->Set(1, new base::StringValue("world")); | 257 args->Set(1, new base::StringValue("world")); |
258 activity_log->LogAPIAction(kExtensionId, | 258 activity_log->LogAPIAction(kExtensionId, |
259 std::string("extension.connect"), | 259 std::string("extension.connect"), |
260 args.get(), | 260 args.get(), |
261 std::string()); | 261 std::string()); |
262 activity_log->GetActions( | 262 activity_log->GetActions( |
263 kExtensionId, 0, base::Bind(ActivityLogTest::Arguments_Present)); | 263 kExtensionId, 0, base::Bind(ActivityLogTest::Arguments_Present)); |
264 } | 264 } |
265 | 265 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 302 |
303 activity_log->GetActions( | 303 activity_log->GetActions( |
304 extension->id(), 0, base::Bind( | 304 extension->id(), 0, base::Bind( |
305 RenderViewActivityLogTest::Arguments_Prerender)); | 305 RenderViewActivityLogTest::Arguments_Prerender)); |
306 | 306 |
307 prerender_manager->CancelAllPrerenders(); | 307 prerender_manager->CancelAllPrerenders(); |
308 } | 308 } |
309 | 309 |
310 } // namespace extensions | 310 } // namespace extensions |
311 | 311 |
OLD | NEW |