| Index: chrome/browser/extensions/bluetooth_event_router_unittest.cc | 
| diff --git a/chrome/browser/extensions/bluetooth_event_router_unittest.cc b/chrome/browser/extensions/bluetooth_event_router_unittest.cc | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..d59571d67167dddcf4a00caec40c6a48b11b062a | 
| --- /dev/null | 
| +++ b/chrome/browser/extensions/bluetooth_event_router_unittest.cc | 
| @@ -0,0 +1,61 @@ | 
| +// Copyright (c) 2012 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 "chrome/browser/extensions/bluetooth_event_router.h" | 
| +#include "chrome/browser/extensions/event_names.h" | 
| +#include "chrome/test/base/testing_profile.h" | 
| +#include "device/bluetooth/test/mock_bluetooth_adapter.h" | 
| +#include "testing/gmock/include/gmock/gmock.h" | 
| +#include "testing/gtest/include/gtest/gtest.h" | 
| + | 
| +namespace { | 
| + | 
| +const char* kAdapterAddress = "Mock Adapter address for testing"; | 
| +const char* kName = "Mock Adapter name for testing"; | 
| +const char* kNonBluetoothEventName = "Non bluetooth event name"; | 
| + | 
| +}  // namespace | 
| + | 
| +namespace extensions { | 
| + | 
| +class ExtensionBluetoothEventRouterTest : public testing::Test { | 
| + public: | 
| +  ExtensionBluetoothEventRouterTest() | 
| +      : mock_adapter_(new testing::StrictMock<device::MockBluetoothAdapter>( | 
| +            kAdapterAddress, kName)), | 
| +        router_(&profile_, mock_adapter_) { | 
| +  } | 
| + | 
| +  virtual ~ExtensionBluetoothEventRouterTest() { | 
| +    EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)); | 
| +  } | 
| + | 
| + protected: | 
| +  TestingProfile profile_; | 
| +  testing::StrictMock<device::MockBluetoothAdapter>* mock_adapter_; | 
| +  ExtensionBluetoothEventRouter router_; | 
| +}; | 
| + | 
| +TEST_F(ExtensionBluetoothEventRouterTest, BluetoothEventListenerAdded) { | 
| +  EXPECT_CALL(*mock_adapter_, AddObserver(testing::_)) | 
| +      .WillOnce(testing::Return()); | 
| +  router_.OnEventListenerAdded( | 
| +      extensions::event_names::kBluetoothOnAvailabilityChanged); | 
| +} | 
| + | 
| +TEST_F(ExtensionBluetoothEventRouterTest, NonBluetoothEventListenerAdded) { | 
| +  router_.OnEventListenerAdded(kNonBluetoothEventName); | 
| +} | 
| + | 
| +TEST_F(ExtensionBluetoothEventRouterTest, | 
| +       BluetoothEventListenerAddedTwiceButAddObserverOnce) { | 
| +  EXPECT_CALL(*mock_adapter_, AddObserver(testing::_)) | 
| +      .WillOnce(testing::Return()); | 
| +  router_.OnEventListenerAdded( | 
| +      extensions::event_names::kBluetoothOnAvailabilityChanged); | 
| +  router_.OnEventListenerAdded( | 
| +      extensions::event_names::kBluetoothOnAvailabilityChanged); | 
| +} | 
| + | 
| +}  // namespace extensions | 
|  |