| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/usb/usb_context.h" | |
| 6 | |
| 7 #include "base/threading/platform_thread.h" | 5 #include "base/threading/platform_thread.h" |
| 8 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 7 #include "components/usb_service/usb_context.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "third_party/libusb/src/libusb/libusb.h" | 9 #include "third_party/libusb/src/libusb/libusb.h" |
| 11 | 10 |
| 11 using usb_service::UsbContext; |
| 12 using usb_service::PlatformUsbContext; |
| 13 |
| 12 namespace { | 14 namespace { |
| 13 | 15 |
| 14 class UsbContextTest : public testing::Test { | 16 class UsbContextTest : public testing::Test { |
| 15 protected: | 17 protected: |
| 16 class UsbContextForTest : public UsbContext { | 18 class UsbContextForTest : public UsbContext { |
| 17 public: | 19 public: |
| 18 explicit UsbContextForTest(PlatformUsbContext context) | 20 explicit UsbContextForTest(PlatformUsbContext context) |
| 19 : UsbContext(context) {} | 21 : UsbContext(context) {} |
| 22 |
| 20 private: | 23 private: |
| 21 virtual ~UsbContextForTest() {} | 24 virtual ~UsbContextForTest() {} |
| 22 DISALLOW_COPY_AND_ASSIGN(UsbContextForTest); | 25 DISALLOW_COPY_AND_ASSIGN(UsbContextForTest); |
| 23 }; | 26 }; |
| 24 }; | 27 }; |
| 25 | 28 |
| 26 } // namespace | 29 } // namespace |
| 27 | 30 |
| 28 #if defined(OS_LINUX) | 31 #if defined(OS_LINUX) |
| 29 // Linux trybot does not support usb. | 32 // Linux trybot does not support usb. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 41 PlatformUsbContext platform_context; | 44 PlatformUsbContext platform_context; |
| 42 ASSERT_EQ(LIBUSB_SUCCESS, libusb_init(&platform_context)); | 45 ASSERT_EQ(LIBUSB_SUCCESS, libusb_init(&platform_context)); |
| 43 scoped_refptr<UsbContextForTest> context( | 46 scoped_refptr<UsbContextForTest> context( |
| 44 new UsbContextForTest(platform_context)); | 47 new UsbContextForTest(platform_context)); |
| 45 } | 48 } |
| 46 base::TimeDelta elapse = base::TimeTicks::Now() - start; | 49 base::TimeDelta elapse = base::TimeTicks::Now() - start; |
| 47 if (elapse > base::TimeDelta::FromSeconds(2)) { | 50 if (elapse > base::TimeDelta::FromSeconds(2)) { |
| 48 FAIL(); | 51 FAIL(); |
| 49 } | 52 } |
| 50 } | 53 } |
| OLD | NEW |