input_service_linux_unittest.cc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include <stddef.h>
  5. #include <vector>
  6. #include "base/bind.h"
  7. #include "base/files/file_descriptor_watcher_posix.h"
  8. #include "base/run_loop.h"
  9. #include "base/test/task_environment.h"
  10. #include "services/device/hid/input_service_linux.h"
  11. #include "services/device/public/mojom/input_service.mojom.h"
  12. #include "testing/gtest/include/gtest/gtest.h"
  13. namespace device {
  14. namespace {
  15. void OnGetDevices(base::OnceClosure quit_closure,
  16. std::vector<mojom::InputDeviceInfoPtr> devices) {
  17. for (size_t i = 0; i < devices.size(); ++i)
  18. ASSERT_TRUE(!devices[i]->id.empty());
  19. std::move(quit_closure).Run();
  20. }
  21. } // namespace
  22. TEST(InputServiceLinux, Simple) {
  23. base::test::TaskEnvironment task_environment(
  24. base::test::TaskEnvironment::MainThreadType::IO);
  25. InputServiceLinux* service = InputServiceLinux::GetInstance();
  26. ASSERT_TRUE(service);
  27. base::RunLoop run_loop;
  28. service->GetDevices(base::BindOnce(&OnGetDevices, run_loop.QuitClosure()));
  29. run_loop.Run();
  30. }
  31. } // namespace device