| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 "", | 229 "", |
| 230 "", | 230 "", |
| 231 "", | 231 "", |
| 232 0, | 232 0, |
| 233 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions2)); | 233 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions2)); |
| 234 } | 234 } |
| 235 | 235 |
| 236 TEST_F(ActivityLogTest, LogPrerender) { | 236 TEST_F(ActivityLogTest, LogPrerender) { |
| 237 scoped_refptr<const Extension> extension = | 237 scoped_refptr<const Extension> extension = |
| 238 ExtensionBuilder() | 238 ExtensionBuilder() |
| 239 .SetManifest(std::move(DictionaryBuilder() | 239 .SetManifest(DictionaryBuilder() |
| 240 .Set("name", "Test extension") | 240 .Set("name", "Test extension") |
| 241 .Set("version", "1.0.0") | 241 .Set("version", "1.0.0") |
| 242 .Set("manifest_version", 2))) | 242 .Set("manifest_version", 2) |
| 243 .Build()) |
| 243 .Build(); | 244 .Build(); |
| 244 extension_service_->AddExtension(extension.get()); | 245 extension_service_->AddExtension(extension.get()); |
| 245 ActivityLog* activity_log = ActivityLog::GetInstance(profile()); | 246 ActivityLog* activity_log = ActivityLog::GetInstance(profile()); |
| 246 ASSERT_TRUE(GetDatabaseEnabled()); | 247 ASSERT_TRUE(GetDatabaseEnabled()); |
| 247 GURL url("http://www.google.com"); | 248 GURL url("http://www.google.com"); |
| 248 | 249 |
| 249 prerender::PrerenderManager* prerender_manager = | 250 prerender::PrerenderManager* prerender_manager = |
| 250 prerender::PrerenderManagerFactory::GetForProfile( | 251 prerender::PrerenderManagerFactory::GetForProfile( |
| 251 Profile::FromBrowserContext(profile())); | 252 Profile::FromBrowserContext(profile())); |
| 252 | 253 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 action->mutable_args()->AppendString("/api/"); | 324 action->mutable_args()->AppendString("/api/"); |
| 324 action->mutable_other()->SetInteger(activity_log_constants::kActionDomVerb, | 325 action->mutable_other()->SetInteger(activity_log_constants::kActionDomVerb, |
| 325 DomActionType::METHOD); | 326 DomActionType::METHOD); |
| 326 activity_log->LogAction(action); | 327 activity_log->LogAction(action); |
| 327 | 328 |
| 328 // Submit an API call with an embedded URL. | 329 // Submit an API call with an embedded URL. |
| 329 action = new Action(kExtensionId, | 330 action = new Action(kExtensionId, |
| 330 now - base::TimeDelta::FromSeconds(3), | 331 now - base::TimeDelta::FromSeconds(3), |
| 331 Action::ACTION_API_CALL, | 332 Action::ACTION_API_CALL, |
| 332 "windows.create"); | 333 "windows.create"); |
| 333 action->set_args(ListBuilder() | 334 action->set_args( |
| 334 .Append(std::move(DictionaryBuilder().Set( | 335 ListBuilder() |
| 335 "url", "http://www.google.co.uk"))) | 336 .Append( |
| 336 .Build()); | 337 DictionaryBuilder().Set("url", "http://www.google.co.uk").Build()) |
| 338 .Build()); |
| 337 activity_log->LogAction(action); | 339 activity_log->LogAction(action); |
| 338 | 340 |
| 339 activity_log->GetFilteredActions( | 341 activity_log->GetFilteredActions( |
| 340 kExtensionId, | 342 kExtensionId, |
| 341 Action::ACTION_ANY, | 343 Action::ACTION_ANY, |
| 342 "", | 344 "", |
| 343 "", | 345 "", |
| 344 "", | 346 "", |
| 345 -1, | 347 -1, |
| 346 base::Bind(ActivityLogTest::RetrieveActions_ArgUrlExtraction)); | 348 base::Bind(ActivityLogTest::RetrieveActions_ArgUrlExtraction)); |
| 347 } | 349 } |
| 348 | 350 |
| 349 TEST_F(ActivityLogTest, UninstalledExtension) { | 351 TEST_F(ActivityLogTest, UninstalledExtension) { |
| 350 scoped_refptr<const Extension> extension = | 352 scoped_refptr<const Extension> extension = |
| 351 ExtensionBuilder() | 353 ExtensionBuilder() |
| 352 .SetManifest(std::move(DictionaryBuilder() | 354 .SetManifest(DictionaryBuilder() |
| 353 .Set("name", "Test extension") | 355 .Set("name", "Test extension") |
| 354 .Set("version", "1.0.0") | 356 .Set("version", "1.0.0") |
| 355 .Set("manifest_version", 2))) | 357 .Set("manifest_version", 2) |
| 358 .Build()) |
| 356 .Build(); | 359 .Build(); |
| 357 | 360 |
| 358 ActivityLog* activity_log = ActivityLog::GetInstance(profile()); | 361 ActivityLog* activity_log = ActivityLog::GetInstance(profile()); |
| 359 scoped_ptr<base::ListValue> args(new base::ListValue()); | 362 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 360 ASSERT_TRUE(GetDatabaseEnabled()); | 363 ASSERT_TRUE(GetDatabaseEnabled()); |
| 361 | 364 |
| 362 // Write some API calls | 365 // Write some API calls |
| 363 scoped_refptr<Action> action = new Action(extension->id(), | 366 scoped_refptr<Action> action = new Action(extension->id(), |
| 364 base::Time::Now(), | 367 base::Time::Now(), |
| 365 Action::ACTION_API_CALL, | 368 Action::ACTION_API_CALL, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 kExtensionId, | 408 kExtensionId, |
| 406 Action::ACTION_ANY, | 409 Action::ACTION_ANY, |
| 407 "", | 410 "", |
| 408 "", | 411 "", |
| 409 "", | 412 "", |
| 410 -1, | 413 -1, |
| 411 base::Bind(ActivityLogTest::RetrieveActions_ArgUrlApiCalls)); | 414 base::Bind(ActivityLogTest::RetrieveActions_ArgUrlApiCalls)); |
| 412 } | 415 } |
| 413 | 416 |
| 414 } // namespace extensions | 417 } // namespace extensions |
| OLD | NEW |