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

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

Issue 1739183003: Make extensions::DictionaryBuilder and extensions::ListValue unmovable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/extensions/activity_log/counting_policy.h" 5 #include "chrome/browser/extensions/activity_log/counting_policy.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 chromeos::ScopedTestCrosSettings test_cros_settings_; 533 chromeos::ScopedTestCrosSettings test_cros_settings_;
534 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_; 534 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_;
535 #endif 535 #endif
536 }; 536 };
537 537
538 TEST_F(CountingPolicyTest, Construct) { 538 TEST_F(CountingPolicyTest, Construct) {
539 ActivityLogDatabasePolicy* policy = new CountingPolicy(profile_.get()); 539 ActivityLogDatabasePolicy* policy = new CountingPolicy(profile_.get());
540 policy->Init(); 540 policy->Init();
541 scoped_refptr<const Extension> extension = 541 scoped_refptr<const Extension> extension =
542 ExtensionBuilder() 542 ExtensionBuilder()
543 .SetManifest(std::move(DictionaryBuilder() 543 .SetManifest(DictionaryBuilder()
544 .Set("name", "Test extension") 544 .Set("name", "Test extension")
545 .Set("version", "1.0.0") 545 .Set("version", "1.0.0")
546 .Set("manifest_version", 2))) 546 .Set("manifest_version", 2)
547 .Build())
547 .Build(); 548 .Build();
548 extension_service_->AddExtension(extension.get()); 549 extension_service_->AddExtension(extension.get());
549 scoped_ptr<base::ListValue> args(new base::ListValue()); 550 scoped_ptr<base::ListValue> args(new base::ListValue());
550 scoped_refptr<Action> action = new Action(extension->id(), 551 scoped_refptr<Action> action = new Action(extension->id(),
551 base::Time::Now(), 552 base::Time::Now(),
552 Action::ACTION_API_CALL, 553 Action::ACTION_API_CALL,
553 "tabs.testMethod"); 554 "tabs.testMethod");
554 action->set_args(std::move(args)); 555 action->set_args(std::move(args));
555 policy->ProcessAction(action); 556 policy->ProcessAction(action);
556 policy->Close(); 557 policy->Close();
557 } 558 }
558 559
559 TEST_F(CountingPolicyTest, LogWithStrippedArguments) { 560 TEST_F(CountingPolicyTest, LogWithStrippedArguments) {
560 ActivityLogDatabasePolicy* policy = new CountingPolicy(profile_.get()); 561 ActivityLogDatabasePolicy* policy = new CountingPolicy(profile_.get());
561 policy->Init(); 562 policy->Init();
562 scoped_refptr<const Extension> extension = 563 scoped_refptr<const Extension> extension =
563 ExtensionBuilder() 564 ExtensionBuilder()
564 .SetManifest(std::move(DictionaryBuilder() 565 .SetManifest(DictionaryBuilder()
565 .Set("name", "Test extension") 566 .Set("name", "Test extension")
566 .Set("version", "1.0.0") 567 .Set("version", "1.0.0")
567 .Set("manifest_version", 2))) 568 .Set("manifest_version", 2)
569 .Build())
568 .Build(); 570 .Build();
569 extension_service_->AddExtension(extension.get()); 571 extension_service_->AddExtension(extension.get());
570 572
571 scoped_ptr<base::ListValue> args(new base::ListValue()); 573 scoped_ptr<base::ListValue> args(new base::ListValue());
572 args->Set(0, new base::StringValue("hello")); 574 args->Set(0, new base::StringValue("hello"));
573 args->Set(1, new base::StringValue("world")); 575 args->Set(1, new base::StringValue("world"));
574 scoped_refptr<Action> action = new Action(extension->id(), 576 scoped_refptr<Action> action = new Action(extension->id(),
575 base::Time::Now(), 577 base::Time::Now(),
576 Action::ACTION_API_CALL, 578 Action::ACTION_API_CALL,
577 "extension.connect"); 579 "extension.connect");
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 base::Bind(&CountingPolicyTest::Arguments_GetOlderActions)); 702 base::Bind(&CountingPolicyTest::Arguments_GetOlderActions));
701 703
702 policy->Close(); 704 policy->Close();
703 } 705 }
704 706
705 TEST_F(CountingPolicyTest, LogAndFetchFilteredActions) { 707 TEST_F(CountingPolicyTest, LogAndFetchFilteredActions) {
706 ActivityLogDatabasePolicy* policy = new CountingPolicy(profile_.get()); 708 ActivityLogDatabasePolicy* policy = new CountingPolicy(profile_.get());
707 policy->Init(); 709 policy->Init();
708 scoped_refptr<const Extension> extension = 710 scoped_refptr<const Extension> extension =
709 ExtensionBuilder() 711 ExtensionBuilder()
710 .SetManifest(std::move(DictionaryBuilder() 712 .SetManifest(DictionaryBuilder()
711 .Set("name", "Test extension") 713 .Set("name", "Test extension")
712 .Set("version", "1.0.0") 714 .Set("version", "1.0.0")
713 .Set("manifest_version", 2))) 715 .Set("manifest_version", 2)
716 .Build())
714 .Build(); 717 .Build();
715 extension_service_->AddExtension(extension.get()); 718 extension_service_->AddExtension(extension.get());
716 GURL gurl("http://www.google.com"); 719 GURL gurl("http://www.google.com");
717 720
718 // Write some API calls 721 // Write some API calls
719 scoped_refptr<Action> action_api = new Action(extension->id(), 722 scoped_refptr<Action> action_api = new Action(extension->id(),
720 base::Time::Now(), 723 base::Time::Now(),
721 Action::ACTION_API_CALL, 724 Action::ACTION_API_CALL,
722 "tabs.testMethod"); 725 "tabs.testMethod");
723 action_api->set_args(make_scoped_ptr(new base::ListValue())); 726 action_api->set_args(make_scoped_ptr(new base::ListValue()));
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 1417
1415 action_ids.push_back(2); 1418 action_ids.push_back(2);
1416 CheckRemoveActions( 1419 CheckRemoveActions(
1417 policy, action_ids, base::Bind(&CountingPolicyTest::Action2Deleted)); 1420 policy, action_ids, base::Bind(&CountingPolicyTest::Action2Deleted));
1418 action_ids.clear(); 1421 action_ids.clear();
1419 1422
1420 policy->Close(); 1423 policy->Close();
1421 } 1424 }
1422 1425
1423 } // namespace extensions 1426 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698