OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/power_data_collector.h" | 5 #include "chrome/browser/chromeos/power/power_data_collector.h" |
6 #include "chromeos/dbus/dbus_thread_manager.h" | 6 #include "chromeos/dbus/dbus_thread_manager.h" |
7 #include "chromeos/dbus/fake_dbus_thread_manager.h" | |
8 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" | 7 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
10 | 9 |
11 namespace chromeos { | 10 namespace chromeos { |
12 | 11 |
13 class PowerDataCollectorTest : public testing::Test { | 12 class PowerDataCollectorTest : public testing::Test { |
14 public: | 13 public: |
15 PowerDataCollectorTest() : power_data_collector_(NULL) {} | 14 PowerDataCollectorTest() : power_data_collector_(NULL) {} |
16 virtual ~PowerDataCollectorTest() {} | 15 virtual ~PowerDataCollectorTest() {} |
17 | 16 |
18 virtual void SetUp() OVERRIDE { | 17 virtual void SetUp() OVERRIDE { |
19 FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager; | 18 DBusThreadManager::Initialize(); |
20 fake_dbus_thread_manager->SetFakeClients(); | |
21 DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager); | |
22 PowerDataCollector::InitializeForTesting(); | 19 PowerDataCollector::InitializeForTesting(); |
23 power_data_collector_ = PowerDataCollector::Get(); | 20 power_data_collector_ = PowerDataCollector::Get(); |
24 } | 21 } |
25 | 22 |
26 virtual void TearDown() OVERRIDE { | 23 virtual void TearDown() OVERRIDE { |
27 PowerDataCollector::Shutdown(); | 24 PowerDataCollector::Shutdown(); |
28 DBusThreadManager::Shutdown(); | 25 DBusThreadManager::Shutdown(); |
29 power_data_collector_ = NULL; | 26 power_data_collector_ = NULL; |
30 } | 27 } |
31 | 28 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 AddSample(&sample_deque, sample1); | 76 AddSample(&sample_deque, sample1); |
80 ASSERT_EQ(static_cast<size_t>(1), sample_deque.size()); | 77 ASSERT_EQ(static_cast<size_t>(1), sample_deque.size()); |
81 | 78 |
82 AddSample(&sample_deque, sample2); | 79 AddSample(&sample_deque, sample2); |
83 ASSERT_EQ(static_cast<size_t>(1), sample_deque.size()); | 80 ASSERT_EQ(static_cast<size_t>(1), sample_deque.size()); |
84 EXPECT_EQ(sample2.time.ToInternalValue(), | 81 EXPECT_EQ(sample2.time.ToInternalValue(), |
85 sample_deque[0].time.ToInternalValue()); | 82 sample_deque[0].time.ToInternalValue()); |
86 } | 83 } |
87 | 84 |
88 } // namespace chromeos | 85 } // namespace chromeos |
OLD | NEW |