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

Side by Side Diff: components/usb_service/usb_context_unittest.cc

Issue 497363004: Merge components/usb_service into device/usb. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « components/usb_service/usb_context.cc ('k') | components/usb_service/usb_device.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
5 #include "base/threading/platform_thread.h"
6 #include "build/build_config.h"
7 #include "components/usb_service/usb_context.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/libusb/src/libusb/libusb.h"
10
11 using usb_service::UsbContext;
12 using usb_service::PlatformUsbContext;
13
14 namespace {
15
16 class UsbContextTest : public testing::Test {
17 protected:
18 class UsbContextForTest : public UsbContext {
19 public:
20 explicit UsbContextForTest(PlatformUsbContext context)
21 : UsbContext(context) {}
22
23 private:
24 virtual ~UsbContextForTest() {}
25 DISALLOW_COPY_AND_ASSIGN(UsbContextForTest);
26 };
27 };
28
29 } // namespace
30
31 #if defined(OS_LINUX)
32 // Linux trybot does not support usb.
33 #define MAYBE_GracefulShutdown DISABLED_GracefulShutdown
34 #elif defined(OS_ANDROID)
35 // Android build does not include usb support.
36 #define MAYBE_GracefulShutdown DISABLED_GracefulShutdown
37 #else
38 #define MAYBE_GracefulShutdown GracefulShutdown
39 #endif
40
41 TEST_F(UsbContextTest, MAYBE_GracefulShutdown) {
42 base::TimeTicks start = base::TimeTicks::Now();
43 {
44 PlatformUsbContext platform_context;
45 ASSERT_EQ(LIBUSB_SUCCESS, libusb_init(&platform_context));
46 scoped_refptr<UsbContextForTest> context(
47 new UsbContextForTest(platform_context));
48 }
49 base::TimeDelta elapse = base::TimeTicks::Now() - start;
50 if (elapse > base::TimeDelta::FromSeconds(2)) {
51 FAIL();
52 }
53 }
OLDNEW
« no previous file with comments | « components/usb_service/usb_context.cc ('k') | components/usb_service/usb_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698