| 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 "battery_status_dispatcher.h" | 5 #include "battery_status_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "content/common/battery_status_messages.h" | 9 #include "content/common/battery_status_messages.h" |
| 10 #include "content/public/test/mock_render_thread.h" | 10 #include "content/public/test/mock_render_thread.h" |
| 11 #include "content/public/test/test_utils.h" | 11 #include "content/public/test/test_utils.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "third_party/WebKit/public/platform/WebBatteryStatusListener.h" | 13 #include "third_party/WebKit/public/platform/WebBatteryStatusListener.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 class MockBatteryStatusListener : public blink::WebBatteryStatusListener { | 17 class MockBatteryStatusListener : public blink::WebBatteryStatusListener { |
| 18 public: | 18 public: |
| 19 MockBatteryStatusListener() : did_change_battery_status_(false) { } | 19 MockBatteryStatusListener() : did_change_battery_status_(false) { } |
| 20 virtual ~MockBatteryStatusListener() { } | 20 virtual ~MockBatteryStatusListener() { } |
| 21 | 21 |
| 22 // blink::WebBatteryStatusListener method. | 22 // blink::WebBatteryStatusListener method. |
| 23 virtual void updateBatteryStatus( | 23 virtual void updateBatteryStatus( |
| 24 const blink::WebBatteryStatus& status) OVERRIDE { | 24 const blink::WebBatteryStatus& status) override { |
| 25 status_ = status; | 25 status_ = status; |
| 26 did_change_battery_status_ = true; | 26 did_change_battery_status_ = true; |
| 27 } | 27 } |
| 28 | 28 |
| 29 const blink::WebBatteryStatus& status() const { return status_; } | 29 const blink::WebBatteryStatus& status() const { return status_; } |
| 30 bool did_change_battery_status() const { return did_change_battery_status_; } | 30 bool did_change_battery_status() const { return did_change_battery_status_; } |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 bool did_change_battery_status_; | 33 bool did_change_battery_status_; |
| 34 blink::WebBatteryStatus status_; | 34 blink::WebBatteryStatus status_; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 dispatcher.Start(0); | 75 dispatcher.Start(0); |
| 76 dispatcher.Stop(); | 76 dispatcher.Stop(); |
| 77 | 77 |
| 78 blink::WebBatteryStatus status; | 78 blink::WebBatteryStatus status; |
| 79 BatteryStatusMsg_DidChange message(status); | 79 BatteryStatusMsg_DidChange message(status); |
| 80 dispatcher.OnControlMessageReceived(message); | 80 dispatcher.OnControlMessageReceived(message); |
| 81 EXPECT_FALSE(listener.did_change_battery_status()); | 81 EXPECT_FALSE(listener.did_change_battery_status()); |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace content | 84 } // namespace content |
| OLD | NEW |