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

Unified Diff: device/usb/usb_service_unittest.cc

Issue 2032303003: Add smoke test for UsbService::GetDevices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « device/test/test_device_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/usb_service_unittest.cc
diff --git a/device/usb/usb_service_unittest.cc b/device/usb/usb_service_unittest.cc
index 6482c9ae695e6b57e1b8319cc23b2e2fc94d796d..d5714ff78716dfb6a8894c0664013d1ae8c44c45 100644
--- a/device/usb/usb_service_unittest.cc
+++ b/device/usb/usb_service_unittest.cc
@@ -4,13 +4,15 @@
#include <memory>
+#include "base/bind.h"
#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/test_io_thread.h"
#include "device/test/test_device_client.h"
#include "device/test/usb_test_gadget.h"
#include "device/usb/usb_device.h"
-#include "device/usb/usb_device_handle.h"
+#include "device/usb/usb_service.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace device {
@@ -31,6 +33,23 @@ class UsbServiceTest : public ::testing::Test {
std::unique_ptr<TestDeviceClient> device_client_;
};
+void OnGetDevices(const base::Closure& quit_closure,
+ const std::vector<scoped_refptr<UsbDevice>>& devices) {
+ quit_closure.Run();
+}
+
+TEST_F(UsbServiceTest, GetDevices) {
+ // Since there's no guarantee that any devices are connected at the moment
+ // this test doesn't assume anything about the result but it at least verifies
+ // that devices can be enumerated without the application crashing.
+ UsbService* service = device_client_->GetUsbService();
+ if (service) {
+ base::RunLoop loop;
+ service->GetDevices(base::Bind(&OnGetDevices, loop.QuitClosure()));
+ loop.Run();
+ }
+}
+
TEST_F(UsbServiceTest, ClaimGadget) {
if (!UsbTestGadget::IsTestEnabled()) return;
« no previous file with comments | « device/test/test_device_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698