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

Side by Side Diff: components/proximity_auth/unlock_manager_unittest.cc

Issue 1316543003: Refactor ProximityAuthUIDelegate functions to ProximityAuthClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/proximity_auth/unlock_manager.h" 5 #include "components/proximity_auth/unlock_manager.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/test/test_simple_task_runner.h" 10 #include "base/test/test_simple_task_runner.h"
11 #include "base/thread_task_runner_handle.h" 11 #include "base/thread_task_runner_handle.h"
12 #include "components/proximity_auth/client.h" 12 #include "components/proximity_auth/client.h"
13 #include "components/proximity_auth/controller.h" 13 #include "components/proximity_auth/controller.h"
14 #include "components/proximity_auth/logging/logging.h" 14 #include "components/proximity_auth/logging/logging.h"
15 #include "components/proximity_auth/proximity_auth_client.h" 15 #include "components/proximity_auth/mock_proximity_auth_client.h"
16 #include "components/proximity_auth/proximity_monitor.h" 16 #include "components/proximity_auth/proximity_monitor.h"
17 #include "components/proximity_auth/remote_status_update.h" 17 #include "components/proximity_auth/remote_status_update.h"
18 #include "components/proximity_auth/screenlock_bridge.h" 18 #include "components/proximity_auth/screenlock_bridge.h"
19 #include "device/bluetooth/bluetooth_adapter_factory.h" 19 #include "device/bluetooth/bluetooth_adapter_factory.h"
20 #include "device/bluetooth/test/mock_bluetooth_adapter.h" 20 #include "device/bluetooth/test/mock_bluetooth_adapter.h"
21 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
23 23
24 #if defined(OS_CHROMEOS) 24 #if defined(OS_CHROMEOS)
25 #include "chromeos/dbus/dbus_thread_manager.h" 25 #include "chromeos/dbus/dbus_thread_manager.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 MOCK_METHOD0(Stop, void()); 84 MOCK_METHOD0(Stop, void());
85 MOCK_CONST_METHOD0(GetStrategy, Strategy()); 85 MOCK_CONST_METHOD0(GetStrategy, Strategy());
86 MOCK_CONST_METHOD0(IsUnlockAllowed, bool()); 86 MOCK_CONST_METHOD0(IsUnlockAllowed, bool());
87 MOCK_CONST_METHOD0(IsInRssiRange, bool()); 87 MOCK_CONST_METHOD0(IsInRssiRange, bool());
88 MOCK_METHOD0(RecordProximityMetricsOnAuthSuccess, void()); 88 MOCK_METHOD0(RecordProximityMetricsOnAuthSuccess, void());
89 89
90 private: 90 private:
91 DISALLOW_COPY_AND_ASSIGN(MockProximityMonitor); 91 DISALLOW_COPY_AND_ASSIGN(MockProximityMonitor);
92 }; 92 };
93 93
94 class MockProximityAuthClient : public ProximityAuthClient {
95 public:
96 MockProximityAuthClient() {}
97 ~MockProximityAuthClient() override {}
98
99 MOCK_CONST_METHOD0(GetAuthenticatedUsername, std::string());
100 MOCK_METHOD1(UpdateScreenlockState,
101 void(proximity_auth::ScreenlockState state));
102 MOCK_METHOD1(FinalizeUnlock, void(bool success));
103 MOCK_METHOD1(FinalizeSignin, void(const std::string& secret));
104
105 private:
106 DISALLOW_COPY_AND_ASSIGN(MockProximityAuthClient);
107 };
108
109 class FakeLockHandler : public ScreenlockBridge::LockHandler { 94 class FakeLockHandler : public ScreenlockBridge::LockHandler {
110 public: 95 public:
111 FakeLockHandler() {} 96 FakeLockHandler() {}
112 ~FakeLockHandler() override {} 97 ~FakeLockHandler() override {}
113 98
114 // LockHandler: 99 // LockHandler:
115 void ShowBannerMessage(const base::string16& message) override {} 100 void ShowBannerMessage(const base::string16& message) override {}
116 void ShowUserPodCustomIcon( 101 void ShowUserPodCustomIcon(
117 const std::string& user_email, 102 const std::string& user_email,
118 const ScreenlockBridge::UserPodCustomIconOptions& icon) override {} 103 const ScreenlockBridge::UserPodCustomIconOptions& icon) override {}
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 SimulateUserPresentState(); 790 SimulateUserPresentState();
806 791
807 EXPECT_CALL(client_, DispatchUnlockEvent()); 792 EXPECT_CALL(client_, DispatchUnlockEvent());
808 unlock_manager_->OnAuthAttempted(ScreenlockBridge::LockHandler::USER_CLICK); 793 unlock_manager_->OnAuthAttempted(ScreenlockBridge::LockHandler::USER_CLICK);
809 794
810 EXPECT_CALL(proximity_auth_client_, FinalizeUnlock(true)); 795 EXPECT_CALL(proximity_auth_client_, FinalizeUnlock(true));
811 unlock_manager_->OnUnlockEventSent(true); 796 unlock_manager_->OnUnlockEventSent(true);
812 } 797 }
813 798
814 } // namespace proximity_auth 799 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698