1 // Copyright 2018 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "services/device/serial/serial_device_enumerator.h"
9 #include "base/test/task_environment.h"
10 #include "testing/gtest/include/gtest/gtest.h"
16 class SerialDeviceEnumeratorTest : public testing::Test {
18 SerialDeviceEnumeratorTest()
19 : task_environment_(base::test::TaskEnvironment::MainThreadType::IO) {}
20 ~SerialDeviceEnumeratorTest() override = default;
23 base::test::TaskEnvironment task_environment_;
26 TEST_F(SerialDeviceEnumeratorTest, GetDevices) {
27 // There is no guarantee that a test machine will have a serial device
28 // available. The purpose of this test is to ensure that the process of
29 // attempting to enumerate devices does not cause a crash.
30 auto enumerator = SerialDeviceEnumerator::Create(
31 task_environment_.GetMainThreadTaskRunner());
32 ASSERT_TRUE(enumerator);
33 std::vector<mojom::SerialPortInfoPtr> devices = enumerator->GetDevices();