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

Unified Diff: chrome/test/chromedriver/commands_unittest.cc

Issue 2777883003: Remove ScopedVector from chrome/test/chromedriver/ (Closed)
Patch Set: address nit from stgao@ Created 3 years, 9 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
« no previous file with comments | « chrome/test/chromedriver/chrome_launcher.cc ('k') | chrome/test/chromedriver/logging.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/commands_unittest.cc
diff --git a/chrome/test/chromedriver/commands_unittest.cc b/chrome/test/chromedriver/commands_unittest.cc
index 8f61845c5739971de43bb12af76ed0416ffa675b..6e228614e8c76be73b19d1403d4c1838129ccbbc 100644
--- a/chrome/test/chromedriver/commands_unittest.cc
+++ b/chrome/test/chromedriver/commands_unittest.cc
@@ -15,6 +15,7 @@
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/location.h"
+#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/lock.h"
@@ -684,11 +685,11 @@ class MockCommandListener : public CommandListener {
};
Status ExecuteAddListenerToSessionCommand(
- CommandListener* listener,
+ std::unique_ptr<CommandListener> listener,
Session* session,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* return_value) {
- session->command_listeners.push_back(listener);
+ session->command_listeners.push_back(std::move(listener));
return Status(kOk);
}
@@ -722,12 +723,13 @@ TEST(CommandsTest, SuccessNotifyingCommandListeners) {
map[id] = thread;
base::DictionaryValue params;
- std::unique_ptr<MockCommandListener> listener(new MockCommandListener());
- CommandListenerProxy* proxy = new CommandListenerProxy(listener.get());
+ auto listener = base::MakeUnique<MockCommandListener>();
+ auto proxy = base::MakeUnique<CommandListenerProxy>(listener.get());
// We add |proxy| to the session instead of adding |listener| directly so that
// after the session is destroyed by ExecuteQuitSessionCommand, we can still
// verify the listener was called. The session owns and will destroy |proxy|.
- SessionCommand cmd = base::Bind(&ExecuteAddListenerToSessionCommand, proxy);
+ SessionCommand cmd =
+ base::Bind(&ExecuteAddListenerToSessionCommand, base::Passed(&proxy));
base::MessageLoop loop;
base::RunLoop run_loop_addlistener;
@@ -776,10 +778,11 @@ class FailingCommandListener : public CommandListener {
}
};
-void AddListenerToSessionIfSessionExists(CommandListener* listener) {
+void AddListenerToSessionIfSessionExists(
+ std::unique_ptr<CommandListener> listener) {
Session* session = GetThreadLocalSession();
if (session) {
- session->command_listeners.push_back(listener);
+ session->command_listeners.push_back(std::move(listener));
}
}
@@ -812,9 +815,10 @@ TEST(CommandsTest, ErrorNotifyingCommandListeners) {
// In SuccessNotifyingCommandListenersBeforeCommand, we verified BeforeCommand
// was called before (as opposed to after) command execution. We don't need to
// verify this again, so we can just add |listener| with PostTask.
- CommandListener* listener = new FailingCommandListener();
+ auto listener = base::MakeUnique<FailingCommandListener>();
thread->task_runner()->PostTask(
- FROM_HERE, base::Bind(&AddListenerToSessionIfSessionExists, listener));
+ FROM_HERE, base::Bind(&AddListenerToSessionIfSessionExists,
+ base::Passed(&listener)));
base::DictionaryValue params;
// The command should never be executed if BeforeCommand fails for a listener.
« no previous file with comments | « chrome/test/chromedriver/chrome_launcher.cc ('k') | chrome/test/chromedriver/logging.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698