diff options
author | nkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-30 11:33:44 +0000 |
---|---|---|
committer | nkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-30 11:33:44 +0000 |
commit | 0c5fde3c14b1e1f10bfaf5fb41259a39125f9125 (patch) | |
tree | 2ed57ee7614052229c3d7f73fc19cf3a4bc63d45 /device/hid/hid_connection_unittest.cc | |
parent | 25b8cb3a52846019f5aab8107b647cff245ac6fd (diff) | |
download | chromium_src-0c5fde3c14b1e1f10bfaf5fb41259a39125f9125.zip chromium_src-0c5fde3c14b1e1f10bfaf5fb41259a39125f9125.tar.gz chromium_src-0c5fde3c14b1e1f10bfaf5fb41259a39125f9125.tar.bz2 |
Revert 247926 "HID backend"
Breaks CrOS buildbots
http://build.chromium.org/p/chromium.chromiumos/buildstatus?builder=ChromiumOS%20%28daisy%29&number=16073
http://build.chromium.org/p/chromium.chromiumos/buildstatus?builder=ChromiumOS%20%28amd64%29&number=13917
http://build.chromium.org/p/chromium.memory/buildstatus?builder=Chromium%20OS%20%28x86%29%20ASAN&number=8064
> HID backend
>
> BUG=290428
>
> Review URL: https://codereview.chromium.org/143883005
TBR=ikarienator@chromium.org
Review URL: https://codereview.chromium.org/148183015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247934 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device/hid/hid_connection_unittest.cc')
-rw-r--r-- | device/hid/hid_connection_unittest.cc | 139 |
1 files changed, 0 insertions, 139 deletions
diff --git a/device/hid/hid_connection_unittest.cc b/device/hid/hid_connection_unittest.cc deleted file mode 100644 index 40cc478..0000000 --- a/device/hid/hid_connection_unittest.cc +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <string> -#include <vector> - -#include "base/bind.h" -#include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.h" -#include "device/hid/hid_connection.h" -#include "device/hid/hid_service.h" -#include "net/base/io_buffer.h" -#include "testing/gtest/include/gtest/gtest.h" - -// TODO(rockot): Enable tests once ChromeOS HID testing hardware is in place. -#if defined(OS_CHROMEOS) -#define MAYBE_Create DISABLED_Create -#define MAYBE_Read DISABLED_Read -#define MAYBE_Write DISABLED_Write -#else -#define MAYBE_Create Create -#define MAYBE_Read Read -#define MAYBE_Write Write -#endif - -namespace device { - -namespace { - -using net::IOBuffer; - -const int kUSBLUFADemoVID = 0x03eb; -const int kUSBLUFADemoPID = 0x204f; -const uint64_t kReport = 0x0903a65d030f8ec9ULL; - -int g_read_times = 0; -void Read(scoped_refptr<HidConnection> conn); - -void OnRead(scoped_refptr<HidConnection> conn, - scoped_refptr<net::IOBuffer> buffer, - bool success, - size_t bytes) { - EXPECT_TRUE(success); - if (success) { - g_read_times++; - EXPECT_EQ(8U, bytes); - if (bytes == 8) { - uint64_t* data = reinterpret_cast<uint64_t*>(buffer->data()); - EXPECT_EQ(kReport, *data); - } else { - base::MessageLoop::current()->Quit(); - } - } else { - LOG(ERROR) << "~"; - g_read_times++; - } - - if (g_read_times < 3){ - base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(Read, conn)); - } else { - base::MessageLoop::current()->Quit(); - } -} - -void Read(scoped_refptr<HidConnection> conn) { - scoped_refptr<IOBuffer> buffer(new IOBuffer(8)); - conn->Read(buffer, 8, base::Bind(OnRead, conn, buffer)); -} - -void OnWriteNormal(bool success, - size_t bytes) { - ASSERT_TRUE(success); - base::MessageLoop::current()->Quit(); -} - -void WriteNormal(scoped_refptr<HidConnection> conn) { - scoped_refptr<IOBuffer> buffer(new IOBuffer(8)); - *(int64_t*)buffer->data() = kReport; - - conn->Write(buffer, 8, base::Bind(OnWriteNormal)); -} - -} // namespace - -class HidConnectionTest : public testing::Test { - protected: - virtual void SetUp() OVERRIDE { - message_loop_.reset(new base::MessageLoopForIO()); - service_.reset(HidService::CreateInstance()); - ASSERT_TRUE(service_); - - std::vector<HidDeviceInfo> devices; - service_->GetDevices(&devices); - ASSERT_GT(devices.size(), 0U) << "No device found"; - for (std::vector<HidDeviceInfo>::iterator it = devices.begin(); - it != devices.end(); - ++it) { - if (it->vendor_id == kUSBLUFADemoVID && - it->product_id == kUSBLUFADemoPID) { - device_id_ = it->device_id; - return; - } - } - ASSERT_TRUE(false) << "Failed to find target device"; - } - - virtual void TearDown() OVERRIDE { - service_.reset(NULL); - message_loop_.reset(NULL); - } - - std::string device_id_; - scoped_ptr<base::MessageLoopForIO> message_loop_; - scoped_ptr<HidService> service_; -}; - -TEST_F(HidConnectionTest, MAYBE_Create) { - scoped_refptr<HidConnection> connection = service_->Connect(device_id_); - ASSERT_TRUE(connection); -} - -TEST_F(HidConnectionTest, MAYBE_Read) { - scoped_refptr<HidConnection> connection = service_->Connect(device_id_); - - ASSERT_TRUE(connection); - message_loop_->PostTask(FROM_HERE, base::Bind(Read, connection)); - message_loop_->Run(); -} - -TEST_F(HidConnectionTest, MAYBE_Write) { - scoped_refptr<HidConnection> connection = service_->Connect(device_id_); - - ASSERT_TRUE(connection); - message_loop_->PostTask(FROM_HERE, base::Bind(WriteNormal, connection)); - message_loop_->Run(); -} - -} // namespace device |