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

Unified Diff: device/bluetooth/bluetooth_task_manager_win_unittest.cc

Issue 11411130: Implemented BluetoothTaskManagerWin class. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Implemented Unittests Created 8 years 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
Index: device/bluetooth/bluetooth_task_manager_win_unittest.cc
diff --git a/device/bluetooth/bluetooth_task_manager_win_unittest.cc b/device/bluetooth/bluetooth_task_manager_win_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b334275bc89efe0dc0e1426d9b894b6237486d76
--- /dev/null
+++ b/device/bluetooth/bluetooth_task_manager_win_unittest.cc
@@ -0,0 +1,74 @@
+// 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 "base/memory/ref_counted.h"
+#include "base/message_loop.h"
+#include "base/run_loop.h"
+#include "content/public/test/test_browser_thread.h"
+#include "device/bluetooth/bluetooth_task_manager_win.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+class BluetoothTaskObserver : public device::BluetoothTaskManagerWin::Observer {
+ public:
+ BluetoothTaskObserver() : updated_(false) {
+ }
+
+ virtual ~BluetoothTaskObserver() {
+ }
+
+ virtual void AdapterStateChanged(
+ const device::BluetoothTaskManagerWin::AdapterState& state) {
+ updated_ = true;
+ }
+
+ bool updated() const {
+ return updated_;
+ }
+
+ private:
+ bool updated_;
+};
+
+} // namespace
+
+namespace device {
+
+class BluetoothTaskManagerWinTest : public testing::Test {
+ public:
+ BluetoothTaskManagerWinTest()
+ : ui_thread_(content::BrowserThread::UI, &ui_loop_),
+ task_manager_(new BluetoothTaskManagerWin()) {
+ }
+
+ virtual void SetUp() {
+ task_manager_->AddObserver(&observer_);
+ }
+
+ virtual void TearDown() {
+ task_manager_->RemoveObserver(&observer_);
+ }
+
+ protected:
+ MessageLoopForUI ui_loop_;
+ content::TestBrowserThread ui_thread_;
+ scoped_refptr<BluetoothTaskManagerWin> task_manager_;
+ BluetoothTaskObserver observer_;
+};
+
+TEST_F(BluetoothTaskManagerWinTest, NotifyObserver) {
+ task_manager_->StartThread();
+ base::RunLoop run_loop;
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ run_loop.QuitClosure(),
+ base::TimeDelta::FromMilliseconds(100));
+
+ run_loop.Run();
+ task_manager_->StopThread();
+ EXPECT_TRUE(observer_.updated());
+}
+
+} // namespace device

Powered by Google App Engine
This is Rietveld 408576698