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

Side by Side Diff: chrome/browser/chromeos/power/peripheral_battery_observer_browsertest.cc

Issue 477663004: Merged FakedDBusThreadManager with DBusThreadManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/power/peripheral_battery_observer.h" 5 #include "chrome/browser/chromeos/power/peripheral_battery_observer.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/notifications/notification_ui_manager.h" 10 #include "chrome/browser/notifications/notification_ui_manager.h"
11 #include "chrome/test/base/in_process_browser_test.h" 11 #include "chrome/test/base/in_process_browser_test.h"
12 #include "chromeos/dbus/fake_dbus_thread_manager.h" 12 #include "chromeos/dbus/dbus_thread_manager.h"
13 #include "content/public/test/test_utils.h" 13 #include "content/public/test/test_utils.h"
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 using ::testing::_; 17 using ::testing::_;
18 using ::testing::InSequence; 18 using ::testing::InSequence;
19 using ::testing::Return; 19 using ::testing::Return;
20 using ::testing::SaveArg; 20 using ::testing::SaveArg;
21 21
22 namespace { 22 namespace {
23 23
24 const char kTestBatteryPath[] = "/sys/class/power_supply/hid-AA:BB:CC-battery"; 24 const char kTestBatteryPath[] = "/sys/class/power_supply/hid-AA:BB:CC-battery";
25 const char kTestBatteryAddress[] = "cc:bb:aa"; 25 const char kTestBatteryAddress[] = "cc:bb:aa";
26 const char kTestDeviceName[] = "test device"; 26 const char kTestDeviceName[] = "test device";
27 27
28 } // namespace 28 } // namespace
29 29
30 namespace chromeos { 30 namespace chromeos {
31 31
32 class PeripheralBatteryObserverTest : public InProcessBrowserTest { 32 class PeripheralBatteryObserverTest : public InProcessBrowserTest {
33 public: 33 public:
34 PeripheralBatteryObserverTest() {} 34 PeripheralBatteryObserverTest() {}
35 virtual ~PeripheralBatteryObserverTest() {} 35 virtual ~PeripheralBatteryObserverTest() {}
36 36
37 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 37 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
38 FakeDBusThreadManager* fake_dbus_thread_manager = 38 chromeos::DBusThreadManager::Initialize();
39 new FakeDBusThreadManager;
40 fake_dbus_thread_manager->SetFakeClients();
41 DBusThreadManager::SetInstanceForTesting(fake_dbus_thread_manager);
42 InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); 39 InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
43 } 40 }
44 41
45 virtual void SetUpOnMainThread() OVERRIDE { 42 virtual void SetUpOnMainThread() OVERRIDE {
46 observer_.reset(new PeripheralBatteryObserver()); 43 observer_.reset(new PeripheralBatteryObserver());
47 } 44 }
48 45
49 virtual void TearDownOnMainThread() OVERRIDE { 46 virtual void TearDownOnMainThread() OVERRIDE {
50 observer_.reset(); 47 observer_.reset();
51 } 48 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 observer_->PeripheralBatteryStatusReceived(kTestBatteryPath, 144 observer_->PeripheralBatteryStatusReceived(kTestBatteryPath,
148 kTestDeviceName, 5); 145 kTestDeviceName, 5);
149 EXPECT_EQ(observer_->batteries_.count(kTestBatteryAddress), 1u); 146 EXPECT_EQ(observer_->batteries_.count(kTestBatteryAddress), 1u);
150 EXPECT_TRUE(notification_manager->FindById(kTestBatteryAddress) != NULL); 147 EXPECT_TRUE(notification_manager->FindById(kTestBatteryAddress) != NULL);
151 148
152 observer_->RemoveBattery(kTestBatteryAddress); 149 observer_->RemoveBattery(kTestBatteryAddress);
153 EXPECT_FALSE(notification_manager->FindById(kTestBatteryAddress) != NULL); 150 EXPECT_FALSE(notification_manager->FindById(kTestBatteryAddress) != NULL);
154 } 151 }
155 152
156 } // namespace chromeos 153 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698