| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "chrome/browser/chromeos/net/network_throttling_observer.h" | 8 #include "chrome/browser/chromeos/net/network_throttling_observer.h" |
| 9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
| 10 #include "chromeos/dbus/dbus_thread_manager.h" | 10 #include "chromeos/dbus/dbus_thread_manager.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 std::unique_ptr<DBusThreadManagerSetter> dbus_setter = | 30 std::unique_ptr<DBusThreadManagerSetter> dbus_setter = |
| 31 DBusThreadManager::GetSetterForTesting(); | 31 DBusThreadManager::GetSetterForTesting(); |
| 32 mock_manager_client_ = new NiceMock<MockShillManagerClient>(); | 32 mock_manager_client_ = new NiceMock<MockShillManagerClient>(); |
| 33 dbus_setter->SetShillManagerClient( | 33 dbus_setter->SetShillManagerClient( |
| 34 std::unique_ptr<ShillManagerClient>(mock_manager_client_)); | 34 std::unique_ptr<ShillManagerClient>(mock_manager_client_)); |
| 35 NetworkStateHandler::InitializeForTest(); | 35 NetworkStateHandler::InitializeForTest(); |
| 36 NetworkHandler::Initialize(); | 36 NetworkHandler::Initialize(); |
| 37 local_state_ = new TestingPrefServiceSimple(); | 37 local_state_ = new TestingPrefServiceSimple(); |
| 38 local_state_->registry()->RegisterDictionaryPref( | 38 local_state_->registry()->RegisterDictionaryPref( |
| 39 prefs::kNetworkThrottlingEnabled); | 39 prefs::kNetworkThrottlingEnabled); |
| 40 observer_ = base::MakeUnique<NetworkThrottlingObserver>(local_state_); | 40 observer_.reset(new NetworkThrottlingObserver(local_state_)); |
| 41 } | 41 } |
| 42 | 42 |
| 43 ~NetworkThrottlingObserverTest() override { DBusThreadManager::Shutdown(); } | 43 ~NetworkThrottlingObserverTest() override { delete mock_manager_client_; } |
| 44 | 44 |
| 45 std::unique_ptr<base::MessageLoop> message_loop_; | 45 std::unique_ptr<base::MessageLoop> message_loop_; |
| 46 std::unique_ptr<NetworkThrottlingObserver> observer_; | 46 std::unique_ptr<NetworkThrottlingObserver> observer_; |
| 47 TestingPrefServiceSimple* local_state_; | 47 TestingPrefServiceSimple* local_state_; |
| 48 MockShillManagerClient* mock_manager_client_; | 48 MockShillManagerClient* mock_manager_client_; |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 DISALLOW_COPY_AND_ASSIGN(NetworkThrottlingObserverTest); | 51 DISALLOW_COPY_AND_ASSIGN(NetworkThrottlingObserverTest); |
| 52 }; | 52 }; |
| 53 | 53 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 71 | 71 |
| 72 // Clearing the preference should disable throttling | 72 // Clearing the preference should disable throttling |
| 73 EXPECT_CALL(*mock_manager_client_, | 73 EXPECT_CALL(*mock_manager_client_, |
| 74 SetNetworkThrottlingStatus(false, 0, 0, _, _)) | 74 SetNetworkThrottlingStatus(false, 0, 0, _, _)) |
| 75 .Times(1); | 75 .Times(1); |
| 76 local_state_->ClearPref(prefs::kNetworkThrottlingEnabled); | 76 local_state_->ClearPref(prefs::kNetworkThrottlingEnabled); |
| 77 } | 77 } |
| 78 | 78 |
| 79 } // namespace test | 79 } // namespace test |
| 80 } // namespace chromeos | 80 } // namespace chromeos |
| OLD | NEW |