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

Unified Diff: device/u2f/mock_u2f_device.cc

Issue 2821263005: Add U2F request state machines (Closed)
Patch Set: Call Start before adding devices Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/u2f/mock_u2f_device.h ('k') | device/u2f/u2f_apdu_response.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/u2f/mock_u2f_device.cc
diff --git a/device/u2f/mock_u2f_device.cc b/device/u2f/mock_u2f_device.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4f8bdc46f0e691c9c5febcdbde713c7c4d9dbd61
--- /dev/null
+++ b/device/u2f/mock_u2f_device.cc
@@ -0,0 +1,53 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mock_u2f_device.h"
+
+namespace device {
+
+MockU2fDevice::MockU2fDevice() {}
+
+MockU2fDevice::~MockU2fDevice() {}
+
+void MockU2fDevice::DeviceTransact(std::unique_ptr<U2fApduCommand> command,
+ const DeviceCallback& cb) {
+ DeviceTransactPtr(command.get(), cb);
+}
+
+// static
+void MockU2fDevice::NotSatisfied(U2fApduCommand* cmd,
+ const DeviceCallback& cb) {
+ cb.Run(true, base::MakeUnique<U2fApduResponse>(
+ std::vector<uint8_t>(),
+ U2fApduResponse::Status::SW_CONDITIONS_NOT_SATISFIED));
+}
+
+// static
+void MockU2fDevice::WrongData(U2fApduCommand* cmd, const DeviceCallback& cb) {
+ cb.Run(true,
+ base::MakeUnique<U2fApduResponse>(
+ std::vector<uint8_t>(), U2fApduResponse::Status::SW_WRONG_DATA));
+}
+
+// static
+void MockU2fDevice::NoErrorSign(U2fApduCommand* cmd, const DeviceCallback& cb) {
+ cb.Run(true, base::MakeUnique<U2fApduResponse>(
+ std::vector<uint8_t>({kSign}),
+ U2fApduResponse::Status::SW_NO_ERROR));
+}
+
+// static
+void MockU2fDevice::NoErrorRegister(U2fApduCommand* cmd,
+ const DeviceCallback& cb) {
+ cb.Run(true, base::MakeUnique<U2fApduResponse>(
+ std::vector<uint8_t>({kRegister}),
+ U2fApduResponse::Status::SW_NO_ERROR));
+}
+
+// static
+void MockU2fDevice::WinkDoNothing(const WinkCallback& cb) {
+ cb.Run();
+}
+
+} // namespace device
« no previous file with comments | « device/u2f/mock_u2f_device.h ('k') | device/u2f/u2f_apdu_response.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698