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

Unified Diff: chrome/browser/usb/usb_context_unittest.cc

Issue 23571007: Fail gracefully when libusb_init fails (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@usb-safe-exit
Patch Set: Fix tests Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/usb/usb_context.cc ('k') | chrome/browser/usb/usb_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/usb/usb_context_unittest.cc
diff --git a/chrome/browser/usb/usb_context_unittest.cc b/chrome/browser/usb/usb_context_unittest.cc
index 79c7c84dca697ce70bba1b82676d54a06be9e014..dce79f43e88c95549a62ee52c5a1393802dfdb60 100644
--- a/chrome/browser/usb/usb_context_unittest.cc
+++ b/chrome/browser/usb/usb_context_unittest.cc
@@ -7,6 +7,7 @@
#include "base/threading/platform_thread.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/libusb/src/libusb/libusb.h"
namespace {
@@ -14,7 +15,8 @@ class UsbContextTest : public testing::Test {
protected:
class UsbContextForTest : public UsbContext {
public:
- UsbContextForTest() : UsbContext() {}
+ explicit UsbContextForTest(PlatformUsbContext context)
+ : UsbContext(context) {}
private:
virtual ~UsbContextForTest() {}
DISALLOW_COPY_AND_ASSIGN(UsbContextForTest);
@@ -36,7 +38,10 @@ class UsbContextTest : public testing::Test {
TEST_F(UsbContextTest, MAYBE_GracefulShutdown) {
base::TimeTicks start = base::TimeTicks::Now();
{
- scoped_refptr<UsbContextForTest> context(new UsbContextForTest());
+ PlatformUsbContext platform_context;
+ ASSERT_EQ(LIBUSB_SUCCESS, libusb_init(&platform_context));
+ scoped_refptr<UsbContextForTest> context(
+ new UsbContextForTest(platform_context));
}
base::TimeDelta elapse = base::TimeTicks::Now() - start;
if (elapse > base::TimeDelta::FromSeconds(2)) {
« no previous file with comments | « chrome/browser/usb/usb_context.cc ('k') | chrome/browser/usb/usb_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698