1 // Copyright 2013 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.
5 #include "chrome/browser/usb/usb_context.h"
7 #include "base/threading/platform_thread.h"
8 #include "build/build_config.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/libusb/src/libusb/libusb.h"
14 class UsbContextTest : public testing::Test {
16 class UsbContextForTest : public UsbContext {
18 explicit UsbContextForTest(PlatformUsbContext context)
19 : UsbContext(context) {}
21 virtual ~UsbContextForTest() {}
22 DISALLOW_COPY_AND_ASSIGN(UsbContextForTest);
29 // Linux trybot does not support usb.
30 #define MAYBE_GracefulShutdown DISABLED_GracefulShutdown
31 #elif defined(OS_ANDROID)
32 // Android build does not include usb support.
33 #define MAYBE_GracefulShutdown DISABLED_GracefulShutdown
35 #define MAYBE_GracefulShutdown GracefulShutdown
38 TEST_F(UsbContextTest, MAYBE_GracefulShutdown) {
39 base::TimeTicks start = base::TimeTicks::Now();
41 PlatformUsbContext platform_context;
42 ASSERT_EQ(LIBUSB_SUCCESS, libusb_init(&platform_context));
43 scoped_refptr<UsbContextForTest> context(
44 new UsbContextForTest(platform_context));
46 base::TimeDelta elapse = base::TimeTicks::Now() - start;
47 if (elapse > base::TimeDelta::FromSeconds(2)) {