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

Unified Diff: ui/events/event_processor_unittest.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr 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
« no previous file with comments | « ui/events/event_processor.cc ('k') | ui/events/event_rewriter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/event_processor_unittest.cc
diff --git a/ui/events/event_processor_unittest.cc b/ui/events/event_processor_unittest.cc
index 34c98e3a753ccc94c25e5b13d34480505489adba..3f34d09cbf4f98e555811189ca72d8cf8fc6d287 100644
--- a/ui/events/event_processor_unittest.cc
+++ b/ui/events/event_processor_unittest.cc
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/events/event.h"
-
#include <utility>
#include <vector>
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/events/event.h"
#include "ui/events/event_target_iterator.h"
#include "ui/events/event_targeter.h"
#include "ui/events/event_utils.h"
@@ -31,10 +31,10 @@ class EventProcessorTest : public testing::Test {
protected:
// testing::Test:
void SetUp() override {
- processor_.SetRoot(make_scoped_ptr(new TestEventTarget()));
+ processor_.SetRoot(base::WrapUnique(new TestEventTarget()));
processor_.Reset();
root()->SetEventTargeter(
- make_scoped_ptr(new TestEventTargeter(root(), false)));
+ base::WrapUnique(new TestEventTargeter(root(), false)));
}
TestEventTarget* root() {
@@ -61,9 +61,9 @@ class EventProcessorTest : public testing::Test {
};
TEST_F(EventProcessorTest, Basic) {
- scoped_ptr<TestEventTarget> child(new TestEventTarget());
+ std::unique_ptr<TestEventTarget> child(new TestEventTarget());
child->SetEventTargeter(
- make_scoped_ptr(new TestEventTargeter(child.get(), false)));
+ base::WrapUnique(new TestEventTargeter(child.get(), false)));
SetTarget(child.get());
root()->AddChild(std::move(child));
@@ -121,26 +121,27 @@ class ReDispatchEventHandler : public TestEventHandler {
// being processed by another event processor.
TEST_F(EventProcessorTest, NestedEventProcessing) {
// Add one child to the default event processor used in this test suite.
- scoped_ptr<TestEventTarget> child(new TestEventTarget());
+ std::unique_ptr<TestEventTarget> child(new TestEventTarget());
SetTarget(child.get());
root()->AddChild(std::move(child));
// Define a second root target and child.
- scoped_ptr<EventTarget> second_root_scoped(new TestEventTarget());
+ std::unique_ptr<EventTarget> second_root_scoped(new TestEventTarget());
TestEventTarget* second_root =
static_cast<TestEventTarget*>(second_root_scoped.get());
- scoped_ptr<TestEventTarget> second_child(new TestEventTarget());
+ std::unique_ptr<TestEventTarget> second_child(new TestEventTarget());
second_root->SetEventTargeter(
- make_scoped_ptr(new TestEventTargeter(second_child.get(), false)));
+ base::WrapUnique(new TestEventTargeter(second_child.get(), false)));
second_root->AddChild(std::move(second_child));
// Define a second event processor which owns the second root.
- scoped_ptr<TestEventProcessor> second_processor(new TestEventProcessor());
+ std::unique_ptr<TestEventProcessor> second_processor(
+ new TestEventProcessor());
second_processor->SetRoot(std::move(second_root_scoped));
// Indicate that an event which is dispatched to the child target owned by the
// first event processor should be handled by |target_handler| instead.
- scoped_ptr<TestEventHandler> target_handler(
+ std::unique_ptr<TestEventHandler> target_handler(
new ReDispatchEventHandler(second_processor.get(), root()->child_at(0)));
ignore_result(root()->child_at(0)->SetTargetHandler(target_handler.get()));
@@ -175,7 +176,7 @@ TEST_F(EventProcessorTest, NestedEventProcessing) {
// Verifies that OnEventProcessingFinished() is called when an event
// has been handled.
TEST_F(EventProcessorTest, OnEventProcessingFinished) {
- scoped_ptr<TestEventTarget> child(new TestEventTarget());
+ std::unique_ptr<TestEventTarget> child(new TestEventTarget());
child->set_mark_events_as_handled(true);
SetTarget(child.get());
root()->AddChild(std::move(child));
@@ -196,7 +197,7 @@ TEST_F(EventProcessorTest, OnEventProcessingFinished) {
// OnEventProcessingStarted() marks the event as handled. Also verifies that
// OnEventProcessingFinished() is also called in either case.
TEST_F(EventProcessorTest, OnEventProcessingStarted) {
- scoped_ptr<TestEventTarget> child(new TestEventTarget());
+ std::unique_ptr<TestEventTarget> child(new TestEventTarget());
SetTarget(child.get());
root()->AddChild(std::move(child));
@@ -234,12 +235,12 @@ TEST_F(EventProcessorTest, OnEventProcessingStarted) {
// Tests that unhandled events are correctly dispatched to the next-best
// target as decided by the TestEventTargeter.
TEST_F(EventProcessorTest, DispatchToNextBestTarget) {
- scoped_ptr<TestEventTarget> child(new TestEventTarget());
- scoped_ptr<TestEventTarget> grandchild(new TestEventTarget());
+ std::unique_ptr<TestEventTarget> child(new TestEventTarget());
+ std::unique_ptr<TestEventTarget> grandchild(new TestEventTarget());
// Install a TestEventTargeter which permits bubbling.
root()->SetEventTargeter(
- make_scoped_ptr(new TestEventTargeter(grandchild.get(), true)));
+ base::WrapUnique(new TestEventTargeter(grandchild.get(), true)));
child->AddChild(std::move(grandchild));
root()->AddChild(std::move(child));
@@ -308,12 +309,12 @@ TEST_F(EventProcessorTest, DispatchToNextBestTarget) {
// targets, pre-target handlers, and post-target handlers when
// a TestEventTargeter is installed on the root target which permits bubbling.
TEST_F(EventProcessorTest, HandlerSequence) {
- scoped_ptr<TestEventTarget> child(new TestEventTarget());
- scoped_ptr<TestEventTarget> grandchild(new TestEventTarget());
+ std::unique_ptr<TestEventTarget> child(new TestEventTarget());
+ std::unique_ptr<TestEventTarget> grandchild(new TestEventTarget());
// Install a TestEventTargeter which permits bubbling.
root()->SetEventTargeter(
- make_scoped_ptr(new TestEventTargeter(grandchild.get(), true)));
+ base::WrapUnique(new TestEventTargeter(grandchild.get(), true)));
child->AddChild(std::move(grandchild));
root()->AddChild(std::move(child));
« no previous file with comments | « ui/events/event_processor.cc ('k') | ui/events/event_rewriter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698