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

Unified Diff: chrome/browser/extensions/activity_log/counting_policy_unittest.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/activity_log/counting_policy_unittest.cc
diff --git a/chrome/browser/extensions/activity_log/counting_policy_unittest.cc b/chrome/browser/extensions/activity_log/counting_policy_unittest.cc
index 4eca1d996816dca65cad82be52f280445782eb2c..8b08a4abf519791ef0503dcaef8133ffc4b31d36 100644
--- a/chrome/browser/extensions/activity_log/counting_policy_unittest.cc
+++ b/chrome/browser/extensions/activity_log/counting_policy_unittest.cc
@@ -6,12 +6,14 @@
#include <stddef.h>
#include <stdint.h>
+
+#include <memory>
#include <utility>
#include "base/cancelable_callback.h"
#include "base/command_line.h"
#include "base/location.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_split.h"
@@ -82,11 +84,11 @@ class CountingPolicyTest : public testing::Test {
// A wrapper function for CheckReadFilteredData, so that we don't need to
// enter empty string values for parameters we don't care about.
- void CheckReadData(
- ActivityLogDatabasePolicy* policy,
- const std::string& extension_id,
- int day,
- const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker) {
+ void CheckReadData(ActivityLogDatabasePolicy* policy,
+ const std::string& extension_id,
+ int day,
+ const base::Callback<void(
+ std::unique_ptr<Action::ActionVector>)>& checker) {
CheckReadFilteredData(
policy, extension_id, Action::ACTION_ANY, "", "", "", day, checker);
}
@@ -101,7 +103,8 @@ class CountingPolicyTest : public testing::Test {
const std::string& page_url,
const std::string& arg_url,
int day,
- const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker) {
+ const base::Callback<void(std::unique_ptr<Action::ActionVector>)>&
+ checker) {
// Submit a request to the policy to read back some data, and call the
// checker function when results are available. This will happen on the
// database thread.
@@ -149,10 +152,10 @@ class CountingPolicyTest : public testing::Test {
ASSERT_LE(policy->queued_actions_.size(), 200U);
}
- static void CheckWrapper(
- const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker,
- const base::Closure& done,
- scoped_ptr<Action::ActionVector> results) {
+ static void CheckWrapper(const base::Callback<void(
+ std::unique_ptr<Action::ActionVector>)>& checker,
+ const base::Closure& done,
+ std::unique_ptr<Action::ActionVector> results) {
checker.Run(std::move(results));
done.Run();
}
@@ -163,26 +166,26 @@ class CountingPolicyTest : public testing::Test {
}
static void RetrieveActions_FetchFilteredActions0(
- scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
+ std::unique_ptr<std::vector<scoped_refptr<Action>>> i) {
ASSERT_EQ(0, static_cast<int>(i->size()));
}
static void RetrieveActions_FetchFilteredActions1(
- scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
+ std::unique_ptr<std::vector<scoped_refptr<Action>>> i) {
ASSERT_EQ(1, static_cast<int>(i->size()));
}
static void RetrieveActions_FetchFilteredActions2(
- scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
+ std::unique_ptr<std::vector<scoped_refptr<Action>>> i) {
ASSERT_EQ(2, static_cast<int>(i->size()));
}
static void RetrieveActions_FetchFilteredActions300(
- scoped_ptr<std::vector<scoped_refptr<Action> > > i) {
+ std::unique_ptr<std::vector<scoped_refptr<Action>>> i) {
ASSERT_EQ(300, static_cast<int>(i->size()));
}
- static void Arguments_Stripped(scoped_ptr<Action::ActionVector> i) {
+ static void Arguments_Stripped(std::unique_ptr<Action::ActionVector> i) {
scoped_refptr<Action> last = i->front();
CheckAction(*last.get(),
"odlameecjipmbmbejkplpemijjgpljce",
@@ -196,7 +199,7 @@ class CountingPolicyTest : public testing::Test {
}
static void Arguments_GetSinglesAction(
- scoped_ptr<Action::ActionVector> actions) {
+ std::unique_ptr<Action::ActionVector> actions) {
ASSERT_EQ(1, static_cast<int>(actions->size()));
CheckAction(*actions->at(0).get(),
"punky",
@@ -210,7 +213,7 @@ class CountingPolicyTest : public testing::Test {
}
static void Arguments_GetTodaysActions(
- scoped_ptr<Action::ActionVector> actions) {
+ std::unique_ptr<Action::ActionVector> actions) {
ASSERT_EQ(3, static_cast<int>(actions->size()));
CheckAction(*actions->at(0).get(),
"punky",
@@ -242,7 +245,7 @@ class CountingPolicyTest : public testing::Test {
}
static void Arguments_GetOlderActions(
- scoped_ptr<Action::ActionVector> actions) {
+ std::unique_ptr<Action::ActionVector> actions) {
ASSERT_EQ(2, static_cast<int>(actions->size()));
CheckAction(*actions->at(0).get(),
"punky",
@@ -266,7 +269,7 @@ class CountingPolicyTest : public testing::Test {
static void Arguments_CheckMergeCount(
int count,
- scoped_ptr<Action::ActionVector> actions) {
+ std::unique_ptr<Action::ActionVector> actions) {
if (count > 0) {
ASSERT_EQ(1u, actions->size());
CheckAction(*actions->at(0).get(),
@@ -286,7 +289,7 @@ class CountingPolicyTest : public testing::Test {
static void Arguments_CheckMergeCountAndTime(
int count,
const base::Time& time,
- scoped_ptr<Action::ActionVector> actions) {
+ std::unique_ptr<Action::ActionVector> actions) {
if (count > 0) {
ASSERT_EQ(1u, actions->size());
CheckAction(*actions->at(0).get(),
@@ -304,7 +307,7 @@ class CountingPolicyTest : public testing::Test {
}
}
- static void AllURLsRemoved(scoped_ptr<Action::ActionVector> actions) {
+ static void AllURLsRemoved(std::unique_ptr<Action::ActionVector> actions) {
ASSERT_EQ(2, static_cast<int>(actions->size()));
CheckAction(*actions->at(0).get(),
"punky",
@@ -326,7 +329,7 @@ class CountingPolicyTest : public testing::Test {
1);
}
- static void SomeURLsRemoved(scoped_ptr<Action::ActionVector> actions) {
+ static void SomeURLsRemoved(std::unique_ptr<Action::ActionVector> actions) {
// These will be in the vector in reverse time order.
ASSERT_EQ(5, static_cast<int>(actions->size()));
CheckAction(*actions->at(0).get(),
@@ -376,7 +379,7 @@ class CountingPolicyTest : public testing::Test {
1);
}
- static void CheckDuplicates(scoped_ptr<Action::ActionVector> actions) {
+ static void CheckDuplicates(std::unique_ptr<Action::ActionVector> actions) {
ASSERT_EQ(2u, actions->size());
int total_count = 0;
for (size_t i = 0; i < actions->size(); i++) {
@@ -412,13 +415,14 @@ class CountingPolicyTest : public testing::Test {
void CheckRemoveActions(
ActivityLogDatabasePolicy* policy,
const std::vector<int64_t>& action_ids,
- const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker) {
+ const base::Callback<void(std::unique_ptr<Action::ActionVector>)>&
+ checker) {
// Use a mock clock to ensure that events are not recorded on the wrong day
// when the test is run close to local midnight.
base::SimpleTestClock* mock_clock = new base::SimpleTestClock();
mock_clock->SetNow(base::Time::Now().LocalMidnight() +
base::TimeDelta::FromHours(12));
- policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock));
+ policy->SetClockForTesting(std::unique_ptr<base::Clock>(mock_clock));
// Record some actions
scoped_refptr<Action> action =
@@ -459,11 +463,11 @@ class CountingPolicyTest : public testing::Test {
policy->DeleteDatabase();
}
- static void AllActionsDeleted(scoped_ptr<Action::ActionVector> actions) {
+ static void AllActionsDeleted(std::unique_ptr<Action::ActionVector> actions) {
ASSERT_EQ(0, static_cast<int>(actions->size()));
}
- static void NoActionsDeleted(scoped_ptr<Action::ActionVector> actions) {
+ static void NoActionsDeleted(std::unique_ptr<Action::ActionVector> actions) {
// These will be in the vector in reverse time order.
ASSERT_EQ(2, static_cast<int>(actions->size()));
CheckAction(*actions->at(0).get(),
@@ -488,7 +492,7 @@ class CountingPolicyTest : public testing::Test {
ASSERT_EQ(1, actions->at(1)->action_id());
}
- static void Action1Deleted(scoped_ptr<Action::ActionVector> actions) {
+ static void Action1Deleted(std::unique_ptr<Action::ActionVector> actions) {
// These will be in the vector in reverse time order.
ASSERT_EQ(1, static_cast<int>(actions->size()));
CheckAction(*actions->at(0).get(),
@@ -503,7 +507,7 @@ class CountingPolicyTest : public testing::Test {
ASSERT_EQ(2, actions->at(0)->action_id());
}
- static void Action2Deleted(scoped_ptr<Action::ActionVector> actions) {
+ static void Action2Deleted(std::unique_ptr<Action::ActionVector> actions) {
// These will be in the vector in reverse time order.
ASSERT_EQ(1, static_cast<int>(actions->size()));
CheckAction(*actions->at(0).get(),
@@ -520,7 +524,7 @@ class CountingPolicyTest : public testing::Test {
protected:
ExtensionService* extension_service_;
- scoped_ptr<TestingProfile> profile_;
+ std::unique_ptr<TestingProfile> profile_;
content::TestBrowserThreadBundle thread_bundle_;
// Used to preserve a copy of the original command line.
// The test framework will do this itself as well. However, by then,
@@ -531,7 +535,7 @@ class CountingPolicyTest : public testing::Test {
#if defined OS_CHROMEOS
chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
chromeos::ScopedTestCrosSettings test_cros_settings_;
- scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_;
+ std::unique_ptr<chromeos::ScopedTestUserManager> test_user_manager_;
#endif
};
@@ -547,7 +551,7 @@ TEST_F(CountingPolicyTest, Construct) {
.Build())
.Build();
extension_service_->AddExtension(extension.get());
- scoped_ptr<base::ListValue> args(new base::ListValue());
+ std::unique_ptr<base::ListValue> args(new base::ListValue());
scoped_refptr<Action> action = new Action(extension->id(),
base::Time::Now(),
Action::ACTION_API_CALL,
@@ -570,7 +574,7 @@ TEST_F(CountingPolicyTest, LogWithStrippedArguments) {
.Build();
extension_service_->AddExtension(extension.get());
- scoped_ptr<base::ListValue> args(new base::ListValue());
+ std::unique_ptr<base::ListValue> args(new base::ListValue());
args->Set(0, new base::StringValue("hello"));
args->Set(1, new base::StringValue("world"));
scoped_refptr<Action> action = new Action(extension->id(),
@@ -602,7 +606,7 @@ TEST_F(CountingPolicyTest, GetTodaysActions) {
base::SimpleTestClock* mock_clock = new base::SimpleTestClock();
mock_clock->SetNow(base::Time::Now().LocalMidnight() +
base::TimeDelta::FromHours(12));
- policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock));
+ policy->SetClockForTesting(std::unique_ptr<base::Clock>(mock_clock));
// Record some actions
scoped_refptr<Action> action =
@@ -659,7 +663,7 @@ TEST_F(CountingPolicyTest, GetOlderActions) {
base::SimpleTestClock* mock_clock = new base::SimpleTestClock();
mock_clock->SetNow(base::Time::Now().LocalMidnight() +
base::TimeDelta::FromHours(12));
- policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock));
+ policy->SetClockForTesting(std::unique_ptr<base::Clock>(mock_clock));
// Record some actions
scoped_refptr<Action> action =
@@ -723,14 +727,14 @@ TEST_F(CountingPolicyTest, LogAndFetchFilteredActions) {
base::Time::Now(),
Action::ACTION_API_CALL,
"tabs.testMethod");
- action_api->set_args(make_scoped_ptr(new base::ListValue()));
+ action_api->set_args(base::WrapUnique(new base::ListValue()));
policy->ProcessAction(action_api);
scoped_refptr<Action> action_dom = new Action(extension->id(),
base::Time::Now(),
Action::ACTION_DOM_ACCESS,
"document.write");
- action_dom->set_args(make_scoped_ptr(new base::ListValue()));
+ action_dom->set_args(base::WrapUnique(new base::ListValue()));
action_dom->set_page_url(gurl);
policy->ProcessAction(action_dom);
@@ -817,7 +821,7 @@ TEST_F(CountingPolicyTest, MergingAndExpiring) {
base::SimpleTestClock* mock_clock = new base::SimpleTestClock();
mock_clock->SetNow(base::Time::Now().LocalMidnight() +
base::TimeDelta::FromHours(12));
- policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock));
+ policy->SetClockForTesting(std::unique_ptr<base::Clock>(mock_clock));
// The first two actions should be merged; the last one is on a separate day
// and should not be.
@@ -884,7 +888,7 @@ TEST_F(CountingPolicyTest, StringTableCleaning) {
base::SimpleTestClock* mock_clock = new base::SimpleTestClock();
mock_clock->SetNow(base::Time::Now());
- policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock));
+ policy->SetClockForTesting(std::unique_ptr<base::Clock>(mock_clock));
// Insert an action; this should create entries in both the string table (for
// the extension and API name) and the URL table (for page_url).
@@ -940,7 +944,7 @@ TEST_F(CountingPolicyTest, MoreMerging) {
base::SimpleTestClock* mock_clock = new base::SimpleTestClock();
mock_clock->SetNow(base::Time::Now().LocalMidnight() +
base::TimeDelta::FromHours(12));
- policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock));
+ policy->SetClockForTesting(std::unique_ptr<base::Clock>(mock_clock));
// Create an action 2 days ago, then 1 day ago, then 2 days ago. Make sure
// that we end up with two merged records (one for each day), and each has
@@ -1063,7 +1067,7 @@ TEST_F(CountingPolicyTest, RemoveAllURLs) {
base::SimpleTestClock* mock_clock = new base::SimpleTestClock();
mock_clock->SetNow(base::Time::Now().LocalMidnight() +
base::TimeDelta::FromHours(12));
- policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock));
+ policy->SetClockForTesting(std::unique_ptr<base::Clock>(mock_clock));
// Record some actions
scoped_refptr<Action> action =
@@ -1106,7 +1110,7 @@ TEST_F(CountingPolicyTest, RemoveSpecificURLs) {
base::SimpleTestClock* mock_clock = new base::SimpleTestClock();
mock_clock->SetNow(base::Time::Now().LocalMidnight() +
base::TimeDelta::FromHours(12));
- policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock));
+ policy->SetClockForTesting(std::unique_ptr<base::Clock>(mock_clock));
// Record some actions
// This should have the page url and args url cleared.
@@ -1183,7 +1187,7 @@ TEST_F(CountingPolicyTest, RemoveExtensionData) {
base::SimpleTestClock* mock_clock = new base::SimpleTestClock();
mock_clock->SetNow(base::Time::Now().LocalMidnight() +
base::TimeDelta::FromHours(12));
- policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock));
+ policy->SetClockForTesting(std::unique_ptr<base::Clock>(mock_clock));
// Record some actions
scoped_refptr<Action> action = new Action("deleteextensiondata",
@@ -1248,7 +1252,7 @@ TEST_F(CountingPolicyTest, DeleteDatabase) {
base::SimpleTestClock* mock_clock = new base::SimpleTestClock();
mock_clock->SetNow(base::Time::Now().LocalMidnight() +
base::TimeDelta::FromHours(12));
- policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock));
+ policy->SetClockForTesting(std::unique_ptr<base::Clock>(mock_clock));
// Record some actions
scoped_refptr<Action> action =
@@ -1344,7 +1348,7 @@ TEST_F(CountingPolicyTest, DuplicateRows) {
base::SimpleTestClock* mock_clock = new base::SimpleTestClock();
mock_clock->SetNow(base::Time::Now().LocalMidnight() +
base::TimeDelta::FromHours(12));
- policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock));
+ policy->SetClockForTesting(std::unique_ptr<base::Clock>(mock_clock));
// Record two actions with distinct URLs.
scoped_refptr<Action> action;

Powered by Google App Engine
This is Rietveld 408576698