// 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 <vector>

#include "base/message_loop/message_loop.h"
#include "device/hid/hid_service.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace device {

TEST(HidServiceTest, Create) {
  base::MessageLoopForIO message_loop;
  HidService* service = HidService::Create(message_loop.message_loop_proxy());
  ASSERT_TRUE(service);

  std::vector<HidDeviceInfo> devices;
  service->GetDevices(&devices);
  for (std::vector<HidDeviceInfo>::iterator it = devices.begin();
      it != devices.end();
      ++it) {
    ASSERT_TRUE(it->device_id != kInvalidHidDeviceId);
  }
}

}  // namespace device

// 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 <vector>

#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "device/hid/hid_service.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace device {

TEST(HidServiceTest, Create) {
  base::MessageLoopForIO message_loop;
  scoped_ptr<HidService> service(
      HidService::Create(message_loop.message_loop_proxy()));
  ASSERT_TRUE(service);

  std::vector<HidDeviceInfo> devices;
  service->GetDevices(&devices);
  for (std::vector<HidDeviceInfo>::iterator it = devices.begin();
      it != devices.end();
      ++it) {
    ASSERT_TRUE(it->device_id != kInvalidHidDeviceId);
  }
}

}  // namespace device

Fix memory leak in HidServiceTest.Create from r285774
Fix memory leak in HidServiceTest.Create from r285774

To fix tree-closer in Linux ASan LSan Tests (1) since
http://build.chromium.org/p/chromium.memory/builders/Linux%20ASan%20LSan%20Tests%20%281%29/builds/4338

errors like

Direct leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0x44145b in operator new(unsigned long) /usr/local/google/work/chromium/src/third_party/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:55
    #1 0x5e8afd in device::HidService::Create(scoped_refptr\u003Cbase::MessageLoopProxy>) device/hid/hid_service.cc:26
    #2 0x509324 in device::HidServiceTest_Create_Test::TestBody() device/hid/hid_service_unittest.cc:15

BUG=367145
NOTRY=true
NOTREECHECKS=true
TBR=rockot@chromium.org

Review URL: https://codereview.chromium.org/424623002

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@285848 0039d316-1c4b-4281-b951-d872f2087c98
