| 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 240 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_NOARGS); |
| 241 scoped_ptr<ListValue> args(new ListValue()); | 241 scoped_ptr<ListValue> args(new 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 ASSERT_TRUE(activity_log->IsLogEnabled()); | 253 ASSERT_TRUE(activity_log->IsLogEnabled()); |
| 253 | 254 |
| 254 scoped_ptr<ListValue> args(new ListValue()); | 255 scoped_ptr<ListValue> args(new ListValue()); |
| 255 args->Set(0, new base::StringValue("hello")); | 256 args->Set(0, new base::StringValue("hello")); |
| 256 args->Set(1, new base::StringValue("world")); | 257 args->Set(1, new base::StringValue("world")); |
| 257 activity_log->LogAPIAction(kExtensionId, | 258 activity_log->LogAPIAction(kExtensionId, |
| 258 std::string("extension.connect"), | 259 std::string("extension.connect"), |
| 259 args.get(), | 260 args.get(), |
| 260 std::string()); | 261 std::string()); |
| 261 activity_log->GetActions( | 262 activity_log->GetActions( |
| 262 kExtensionId, 0, base::Bind(ActivityLogTest::Arguments_Present)); | 263 kExtensionId, 0, base::Bind(ActivityLogTest::Arguments_Present)); |
| 263 } | 264 } |
| 264 | 265 |
| 265 TEST_F(RenderViewActivityLogTest, LogPrerender) { | 266 TEST_F(RenderViewActivityLogTest, LogPrerender) { |
| 266 scoped_refptr<const Extension> extension = | 267 scoped_refptr<const Extension> extension = |
| 267 ExtensionBuilder() | 268 ExtensionBuilder() |
| 268 .SetManifest(DictionaryBuilder() | 269 .SetManifest(DictionaryBuilder() |
| 269 .Set("name", "Test extension") | 270 .Set("name", "Test extension") |
| 270 .Set("version", "1.0.0") | 271 .Set("version", "1.0.0") |
| 271 .Set("manifest_version", 2)) | 272 .Set("manifest_version", 2)) |
| 272 .Build(); | 273 .Build(); |
| 273 extension_service_->AddExtension(extension.get()); | 274 extension_service_->AddExtension(extension.get()); |
| 274 ActivityLog* activity_log = ActivityLog::GetInstance(profile()); | 275 ActivityLog* activity_log = ActivityLog::GetInstance(profile()); |
| 276 activity_log->SetDefaultPolicy(ActivityLogPolicy::POLICY_FULLSTREAM); |
| 275 ASSERT_TRUE(activity_log->IsLogEnabled()); | 277 ASSERT_TRUE(activity_log->IsLogEnabled()); |
| 276 GURL url("http://www.google.com"); | 278 GURL url("http://www.google.com"); |
| 277 | 279 |
| 278 prerender::PrerenderManager* prerender_manager = | 280 prerender::PrerenderManager* prerender_manager = |
| 279 prerender::PrerenderManagerFactory::GetForProfile( | 281 prerender::PrerenderManagerFactory::GetForProfile( |
| 280 Profile::FromBrowserContext(profile())); | 282 Profile::FromBrowserContext(profile())); |
| 281 | 283 |
| 282 const gfx::Size kSize(640, 480); | 284 const gfx::Size kSize(640, 480); |
| 283 scoped_ptr<prerender::PrerenderHandle> prerender_handle( | 285 scoped_ptr<prerender::PrerenderHandle> prerender_handle( |
| 284 prerender_manager->AddPrerenderFromLocalPredictor( | 286 prerender_manager->AddPrerenderFromLocalPredictor( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 300 | 302 |
| 301 activity_log->GetActions( | 303 activity_log->GetActions( |
| 302 extension->id(), 0, base::Bind( | 304 extension->id(), 0, base::Bind( |
| 303 RenderViewActivityLogTest::Arguments_Prerender)); | 305 RenderViewActivityLogTest::Arguments_Prerender)); |
| 304 | 306 |
| 305 prerender_manager->CancelAllPrerenders(); | 307 prerender_manager->CancelAllPrerenders(); |
| 306 } | 308 } |
| 307 | 309 |
| 308 } // namespace extensions | 310 } // namespace extensions |
| 309 | 311 |
| OLD | NEW |