Add QrCodeShower test 06/310406/5 accepted/tizen/unified/20240508.150742 accepted/tizen/unified/toolchain/20240507.011848 accepted/tizen/unified/x/20240430.094744
authorKrzysztof Malysa <k.malysa@samsung.com>
Fri, 26 Apr 2024 10:06:41 +0000 (12:06 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Mon, 29 Apr 2024 08:32:33 +0000 (08:32 +0000)
Change-Id: I0e530da9b8036c00eb3c83cffb3e51f221004d8a

tests/CMakeLists.txt
tests/qr_code_shower_tests.cpp [new file with mode: 0644]

index aaa84d704062aaf40cef2ac6e05f923c88a21b69..f6d6e4772cc732847899ce92b9e57819e832ec21 100644 (file)
@@ -65,6 +65,7 @@ SET(UNIT_TESTS_SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/base64_tests.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/message_tests.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/ctap_message_processor_tests.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/qr_code_shower_tests.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/crypto/hkdf_unittest.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/crypto/hmac_unittest.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/crypto/sha2_unittest.cpp
diff --git a/tests/qr_code_shower_tests.cpp b/tests/qr_code_shower_tests.cpp
new file mode 100644 (file)
index 0000000..f94e0a4
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ *  Copyright (c) 2024 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+
+#include "qr_code_shower.h"
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+TEST(QrCodeShower, callback_is_called)
+{
+    QrCodeShower qrCodeShower;
+    int calledNumTimes = 0;
+    static constexpr auto callback = [](const char *qrContents, void *userData) {
+        EXPECT_THAT(qrContents, testing::StartsWith("FIDO:/"));
+        ++*static_cast<int *>(userData);
+    };
+    qrCodeShower.ShowQrCode({}, {}, {'m', 'c'}, true, callback, &calledNumTimes);
+    EXPECT_EQ(calledNumTimes, 1);
+}