Index: chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc |
diff --git a/chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc b/chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc |
index 1ce3fa8bbb1dfeb5efddeec121772c8da83abacd..c1509e45f3af0cad8acc8eecce17b68b12e5e6f3 100644 |
--- a/chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc |
+++ b/chrome/browser/extensions/activity_log/fullstream_ui_policy_unittest.cc |
@@ -5,12 +5,14 @@ |
#include "chrome/browser/extensions/activity_log/fullstream_ui_policy.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/stringprintf.h" |
@@ -73,11 +75,11 @@ class FullStreamUIPolicyTest : 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); |
} |
@@ -92,7 +94,8 @@ class FullStreamUIPolicyTest : public testing::Test { |
const std::string& page_url, |
const std::string& arg_url, |
const int days_ago, |
- 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. |
@@ -115,10 +118,10 @@ class FullStreamUIPolicyTest : public testing::Test { |
timeout.Cancel(); |
} |
- 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(); |
} |
@@ -129,31 +132,31 @@ class FullStreamUIPolicyTest : public testing::Test { |
} |
static void RetrieveActions_LogAndFetchActions( |
- 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_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_Present(scoped_ptr<Action::ActionVector> i) { |
+ static void Arguments_Present(std::unique_ptr<Action::ActionVector> i) { |
scoped_refptr<Action> last = i->front(); |
CheckAction(*last.get(), |
"odlameecjipmbmbejkplpemijjgpljce", |
@@ -166,7 +169,7 @@ class FullStreamUIPolicyTest : public testing::Test { |
} |
static void Arguments_GetTodaysActions( |
- 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", |
@@ -187,7 +190,7 @@ class FullStreamUIPolicyTest : 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", |
@@ -207,7 +210,7 @@ class FullStreamUIPolicyTest : 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", |
@@ -227,7 +230,7 @@ class FullStreamUIPolicyTest : public testing::Test { |
""); |
} |
- 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(), |
@@ -297,13 +300,14 @@ class FullStreamUIPolicyTest : 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 = |
@@ -344,11 +348,11 @@ class FullStreamUIPolicyTest : 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(4, static_cast<int>(actions->size())); |
CheckAction(*actions->at(0).get(), |
@@ -389,7 +393,7 @@ class FullStreamUIPolicyTest : public testing::Test { |
ASSERT_EQ(2, actions->at(3)->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(2, static_cast<int>(actions->size())); |
CheckAction(*actions->at(0).get(), |
@@ -412,7 +416,7 @@ class FullStreamUIPolicyTest : public testing::Test { |
ASSERT_EQ(4, actions->at(1)->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(2, static_cast<int>(actions->size())); |
CheckAction(*actions->at(0).get(), |
@@ -437,7 +441,7 @@ class FullStreamUIPolicyTest : 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, |
@@ -448,7 +452,7 @@ class FullStreamUIPolicyTest : 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 |
}; |
@@ -464,7 +468,7 @@ TEST_F(FullStreamUIPolicyTest, 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, |
@@ -493,14 +497,14 @@ TEST_F(FullStreamUIPolicyTest, LogAndFetchActions) { |
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); |
@@ -532,14 +536,14 @@ TEST_F(FullStreamUIPolicyTest, 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); |
@@ -625,7 +629,7 @@ TEST_F(FullStreamUIPolicyTest, LogWithArguments) { |
.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(), |
@@ -654,7 +658,7 @@ TEST_F(FullStreamUIPolicyTest, 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 = |
@@ -700,7 +704,7 @@ TEST_F(FullStreamUIPolicyTest, 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 = |
@@ -753,7 +757,7 @@ TEST_F(FullStreamUIPolicyTest, 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 = |
@@ -796,7 +800,7 @@ TEST_F(FullStreamUIPolicyTest, 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. |
@@ -872,7 +876,7 @@ TEST_F(FullStreamUIPolicyTest, 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", |
@@ -973,14 +977,14 @@ TEST_F(FullStreamUIPolicyTest, DeleteDatabase) { |
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); |