OLD | NEW |
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/fake_dbus_thread_manager.h" |
13 #include "content/public/browser/browser_thread.h" | |
14 #include "content/public/test/test_browser_thread.h" | |
15 #include "content/public/test/test_utils.h" | 13 #include "content/public/test/test_utils.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
18 | 16 |
19 using ::testing::_; | 17 using ::testing::_; |
20 using ::testing::InSequence; | 18 using ::testing::InSequence; |
21 using ::testing::Return; | 19 using ::testing::Return; |
22 using ::testing::SaveArg; | 20 using ::testing::SaveArg; |
23 | 21 |
24 namespace { | 22 namespace { |
25 | 23 |
26 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"; |
27 const char kTestBatteryAddress[] = "cc:bb:aa"; | 25 const char kTestBatteryAddress[] = "cc:bb:aa"; |
28 const char kTestDeviceName[] = "test device"; | 26 const char kTestDeviceName[] = "test device"; |
29 | 27 |
30 } // namespace | 28 } // namespace |
31 | 29 |
32 namespace chromeos { | 30 namespace chromeos { |
33 | 31 |
34 class PeripheralBatteryObserverTest : public InProcessBrowserTest { | 32 class PeripheralBatteryObserverTest : public InProcessBrowserTest { |
35 public: | 33 public: |
36 PeripheralBatteryObserverTest () {} | 34 PeripheralBatteryObserverTest() {} |
37 virtual ~PeripheralBatteryObserverTest () {} | 35 virtual ~PeripheralBatteryObserverTest() {} |
38 | 36 |
39 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 37 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
40 FakeDBusThreadManager* fake_dbus_thread_manager = | 38 FakeDBusThreadManager* fake_dbus_thread_manager = |
41 new FakeDBusThreadManager; | 39 new FakeDBusThreadManager; |
42 fake_dbus_thread_manager->SetFakeClients(); | 40 fake_dbus_thread_manager->SetFakeClients(); |
43 DBusThreadManager::SetInstanceForTesting(fake_dbus_thread_manager); | 41 DBusThreadManager::SetInstanceForTesting(fake_dbus_thread_manager); |
44 InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); | 42 InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); |
45 } | 43 } |
46 | 44 |
47 virtual void SetUpOnMainThread() OVERRIDE { | 45 virtual void SetUpOnMainThread() OVERRIDE { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 observer_->PeripheralBatteryStatusReceived(kTestBatteryPath, | 147 observer_->PeripheralBatteryStatusReceived(kTestBatteryPath, |
150 kTestDeviceName, 5); | 148 kTestDeviceName, 5); |
151 EXPECT_EQ(observer_->batteries_.count(kTestBatteryAddress), 1u); | 149 EXPECT_EQ(observer_->batteries_.count(kTestBatteryAddress), 1u); |
152 EXPECT_TRUE(notification_manager->FindById(kTestBatteryAddress) != NULL); | 150 EXPECT_TRUE(notification_manager->FindById(kTestBatteryAddress) != NULL); |
153 | 151 |
154 observer_->RemoveBattery(kTestBatteryAddress); | 152 observer_->RemoveBattery(kTestBatteryAddress); |
155 EXPECT_FALSE(notification_manager->FindById(kTestBatteryAddress) != NULL); | 153 EXPECT_FALSE(notification_manager->FindById(kTestBatteryAddress) != NULL); |
156 } | 154 } |
157 | 155 |
158 } // namespace chromeos | 156 } // namespace chromeos |
OLD | NEW |