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

Unified Diff: ui/events/ozone/evdev/event_converter_evdev_impl_unittest.cc

Issue 2639043002: Fix double-close in EventConverterEvdevImpl (Closed)
Patch Set: remove base::debug::Alias Created 3 years, 11 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: ui/events/ozone/evdev/event_converter_evdev_impl_unittest.cc
diff --git a/ui/events/ozone/evdev/event_converter_evdev_impl_unittest.cc b/ui/events/ozone/evdev/event_converter_evdev_impl_unittest.cc
index 406451f6203ccda3ac2bb40599d733e7c01f1c3f..720dfd53df939ab41407f1a2da14b22b434788ec 100644
--- a/ui/events/ozone/evdev/event_converter_evdev_impl_unittest.cc
+++ b/ui/events/ozone/evdev/event_converter_evdev_impl_unittest.cc
@@ -22,6 +22,7 @@
#include "ui/events/ozone/evdev/event_converter_test_util.h"
#include "ui/events/ozone/evdev/event_factory_evdev.h"
#include "ui/events/ozone/evdev/keyboard_evdev.h"
+#include "ui/events/ozone/evdev/scoped_input_device.h"
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
namespace ui {
@@ -30,10 +31,10 @@ const char kTestDevicePath[] = "/dev/input/test-device";
class MockEventConverterEvdevImpl : public EventConverterEvdevImpl {
public:
- MockEventConverterEvdevImpl(int fd,
+ MockEventConverterEvdevImpl(ScopedInputDevice fd,
CursorDelegateEvdev* cursor,
DeviceEventDispatcherEvdev* dispatcher)
- : EventConverterEvdevImpl(fd,
+ : EventConverterEvdevImpl(std::move(fd),
base::FilePath(kTestDevicePath),
1,
EventDeviceInfo(),
@@ -94,8 +95,8 @@ class EventConverterEvdevImplTest : public testing::Test {
int evdev_io[2];
if (pipe(evdev_io))
PLOG(FATAL) << "failed pipe";
- events_in_ = evdev_io[0];
- events_out_ = evdev_io[1];
+ ui::ScopedInputDevice events_in(evdev_io[0]);
+ events_out_.reset(evdev_io[1]);
cursor_.reset(new ui::MockCursorEvdev());
@@ -107,15 +108,14 @@ class EventConverterEvdevImplTest : public testing::Test {
base::Unretained(this)));
dispatcher_ =
ui::CreateDeviceEventDispatcherEvdevForTest(event_factory_.get());
- device_.reset(new ui::MockEventConverterEvdevImpl(events_in_, cursor_.get(),
- dispatcher_.get()));
+ device_.reset(new ui::MockEventConverterEvdevImpl(
+ std::move(events_in), cursor_.get(), dispatcher_.get()));
}
void TearDown() override {
device_.reset();
cursor_.reset();
- close(events_in_);
- close(events_out_);
+ events_out_.reset();
}
ui::MockCursorEvdev* cursor() { return cursor_.get(); }
@@ -157,8 +157,7 @@ class EventConverterEvdevImplTest : public testing::Test {
std::vector<std::unique_ptr<ui::Event>> dispatched_events_;
- int events_out_;
- int events_in_;
+ ui::ScopedInputDevice events_out_;
DISALLOW_COPY_AND_ASSIGN(EventConverterEvdevImplTest);
};

Powered by Google App Engine
This is Rietveld 408576698