-
Notifications
You must be signed in to change notification settings - Fork 0
cpp_test first commit #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -249,3 +249,57 @@ jobs: | |||||||
| --openrpc /workspace/docs/openrpc/the-spec/firebolt-open-rpc.json \ | ||||||||
| --app-openrpc /workspace/docs/openrpc/the-spec/firebolt-app-open-rpc.json \ | ||||||||
| --test-exe /workspace/build/test/FireboltClientComponentTests | ||||||||
|
|
||||||||
| cpp_demo_tests: | ||||||||
| permissions: | ||||||||
| contents: read | ||||||||
| packages: read | ||||||||
| needs: [build_docker] | ||||||||
| runs-on: ubuntu-latest | ||||||||
| steps: | ||||||||
| - name: Log in to the Container registry | ||||||||
| uses: docker/login-action@v3 | ||||||||
| with: | ||||||||
| registry: ghcr.io | ||||||||
| username: ${{ github.actor }} | ||||||||
| password: ${{ secrets.GITHUB_TOKEN }} | ||||||||
|
|
||||||||
| - name: Checkout Code | ||||||||
| uses: actions/checkout@v4 | ||||||||
| with: | ||||||||
| fetch-depth: 0 | ||||||||
|
|
||||||||
| - name: Get version | ||||||||
| run: | | ||||||||
| VERSION=$(git describe --tags --dirty --match "v[0-9]*") | ||||||||
| echo "VERSION=$VERSION" >> $GITHUB_ENV | ||||||||
| echo "version: $VERSION" | ||||||||
|
|
||||||||
| - name: Configure Project with Demo | ||||||||
| run: | | ||||||||
| docker run --rm --user "$(id -u):$(id -g)" -v ${{ github.workspace }}:/workspace ${{ needs.build_docker.outputs.image_tag }} \ | ||||||||
| bash -c " \ | ||||||||
| set -e \ | ||||||||
| && cmake -B build -S . \ | ||||||||
| -DCMAKE_BUILD_TYPE=Debug \ | ||||||||
| -DENABLE_DEMO_APP=ON \ | ||||||||
| " | ||||||||
|
|
||||||||
| - name: Build Project with cpp_test | ||||||||
| run: | | ||||||||
| docker run --rm --user "$(id -u):$(id -g)" -v ${{ github.workspace }}:/workspace ${{ needs.build_docker.outputs.image_tag }} \ | ||||||||
| bash -c " \ | ||||||||
| set -e \ | ||||||||
| && cmake --build build --parallel \ | ||||||||
| " | ||||||||
|
|
||||||||
| - name: Run cpp_test executable | ||||||||
| run: | | ||||||||
| chmod +x ${{ github.workspace }}/build/test/cpp_test/cpp_test | ||||||||
| docker run --rm --user "$(id -u):$(id -g)" -v ${{ github.workspace }}:/workspace ${{ needs.build_docker.outputs.image_tag }} \ | ||||||||
| bash -c " \ | ||||||||
| set -e \ | ||||||||
| && cd /workspace/build/test/cpp_test \ | ||||||||
| && ./cpp_test \ | ||||||||
| " | ||||||||
|
|
||||||||
|
Comment on lines
+304
to
+305
|
||||||||
| " | |
| " |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -91,8 +91,10 @@ add_subdirectory(src) | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (ENABLE_DEMO_APP) | ||||||||||||||||||||||
| add_subdirectory(demo) | ||||||||||||||||||||||
| add_subdirectory(test/cpp_test) #for now | ||||||||||||||||||||||
| endif() | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (ENABLE_TESTS) | ||||||||||||||||||||||
| add_subdirectory(test) | ||||||||||||||||||||||
|
Comment on lines
+94
to
98
|
||||||||||||||||||||||
| add_subdirectory(test/cpp_test) #for now | |
| endif() | |
| if (ENABLE_TESTS) | |
| add_subdirectory(test) | |
| endif() | |
| if (ENABLE_TESTS) | |
| add_subdirectory(test) | |
| add_subdirectory(test/cpp_test) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| cmake_minimum_required(VERSION 3.10) | ||
| project(cpp_test) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 17) | ||
|
|
||
| add_executable(cpp_test | ||
| main.cpp | ||
| cpp/advertisingDemo.cpp | ||
| cpp/accessibilityDemo.cpp | ||
| cpp/chooseInterface.cpp | ||
| cpp/deviceDemo.cpp | ||
| cpp/displayDemo.cpp | ||
| cpp/fireboltdemo.cpp | ||
| cpp/lifecycleDemo.cpp | ||
| cpp/localizationDemo.cpp | ||
| cpp/presentationDemo.cpp | ||
| cpp/statsDemo.cpp | ||
| cpp/utils.cpp | ||
| ) | ||
|
|
||
| list(APPEND CMAKE_PREFIX_PATH ${SYSROOT_PATH}) | ||
|
|
||
| find_package(FireboltTransport) | ||
| find_package(nlohmann_json REQUIRED) | ||
| find_package(nlohmann_json_schema_validator REQUIRED) | ||
| find_package(CURL REQUIRED) | ||
|
|
||
| # Generate header file with embedded JSON content | ||
| file(READ "../../docs/openrpc/the-spec/firebolt-open-rpc.json" JSON_CONTENT) | ||
| configure_file( | ||
| cpp/firebolt-open-rpc.json.in | ||
| "${CMAKE_BINARY_DIR}/generated/firebolt-open-rpc_json.h" | ||
| @ONLY | ||
| ) | ||
|
|
||
| # Make sure your target can find the generated header | ||
| target_include_directories(cpp_test PRIVATE ${CMAKE_BINARY_DIR}/generated) | ||
|
|
||
| target_include_directories(cpp_test PRIVATE | ||
| $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include/> | ||
| $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src/> | ||
| $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/src> | ||
| $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/test/> | ||
| ) | ||
|
|
||
| add_compile_definitions(UT_OPEN_RPC_FILE="firebolt-open-rpc.json") | ||
|
|
||
| target_link_libraries(cpp_test | ||
| FireboltClient | ||
| FireboltTransport::FireboltTransport | ||
| nlohmann_json::nlohmann_json | ||
| nlohmann_json_schema_validator::validator | ||
| CURL::libcurl | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /** | ||
| * Copyright 2025 Comcast Cable Communications Management, LLC | ||
| * | ||
| * 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. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include "accessibilityDemo.h" | ||
| #include <iostream> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include "json_types/jsondata_device_types.h" | ||
|
|
||
| #include "outputstream.h" | ||
| extern OutputStream gOutput; | ||
|
|
||
| using namespace Firebolt; | ||
| using namespace Firebolt::Accessibility; | ||
|
|
||
| AccessibilityDemo::AccessibilityDemo() | ||
| : IFireboltDemo() | ||
| { | ||
| methodsFromRpc("Accessibility"); | ||
| } | ||
|
|
||
| void AccessibilityDemo::runOption(const int index) | ||
| { | ||
| std::string key = names_[index]; | ||
|
|
||
| outStream_ << "Running Accessibility method: " << key << std::endl; | ||
|
|
||
| if (key == "Accessibility.closedCaptionsSettings") | ||
| { | ||
| Result<ClosedCaptionsSettings> r = | ||
| Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().closedCaptionsSettings(); | ||
| if (validateResult(r)) | ||
| { | ||
| ClosedCaptionsSettings settings = r.value(); | ||
| gOutput << "Closed Captions Settings - Enabled: " << (settings.enabled ? "true" : "false") << std::endl; | ||
| } | ||
| } | ||
| else if (key == "Accessibility.audioDescription") | ||
| { | ||
| Result<bool> r = Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().audioDescription(); | ||
| if (validateResult(r)) | ||
| { | ||
| bool enabled = r.value(); | ||
| gOutput << "Audio Description Enabled: " << (enabled ? "true" : "false") << std::endl; | ||
| } | ||
| } | ||
| else if (key == "Accessibility.highContrastUI") | ||
| { | ||
| Result<bool> r = Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().highContrastUI(); | ||
| if (validateResult(r)) | ||
| { | ||
| bool enabled = r.value(); | ||
|
|
||
| gOutput << "High Contrast UI Enabled: " << (enabled ? "true" : "false") << std::endl; | ||
| } | ||
| } | ||
| else if (key == "Accessibility.voiceGuidanceSettings") | ||
| { | ||
| Result<VoiceGuidanceSettings> r = | ||
| Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().voiceGuidanceSettings(); | ||
| if (validateResult(r)) | ||
| { | ||
| VoiceGuidanceSettings settings = r.value(); | ||
| gOutput << "Voice Guidance Settings - Enabled: " << (settings.enabled ? "true" : "false") | ||
| << ", Rate: " << settings.rate << std::endl; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /** | ||
| * Copyright 2025 Comcast Cable Communications Management, LLC | ||
| * | ||
| * 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. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <string> | ||
| #include <vector> | ||
| #include "fireboltdemo.h" | ||
|
|
||
| class AccessibilityDemo : public IFireboltDemo | ||
| { | ||
| public: | ||
| AccessibilityDemo(); | ||
| ~AccessibilityDemo() = default; | ||
| void runOption(const int index); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /** | ||
| * Copyright 2025 Comcast Cable Communications Management, LLC | ||
| * | ||
| * 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. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
|
|
||
| #include "advertisingDemo.h" | ||
| #include <iostream> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include "outputstream.h" | ||
| extern OutputStream gOutput; | ||
|
|
||
| // #include "json_types/jsondata_device_types.h" | ||
|
|
||
| using namespace Firebolt; | ||
| using namespace Firebolt::Advertising; | ||
|
|
||
| AdvertisingDemo::AdvertisingDemo() | ||
| : IFireboltDemo() | ||
| { | ||
| methodsFromRpc("Advertising"); | ||
| } | ||
|
|
||
| void AdvertisingDemo::runOption(const int index) | ||
| { | ||
| std::string key = names_[index]; | ||
|
|
||
| if (key == "Advertising.advertisingId") | ||
| { | ||
| Result<Ifa> result = Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().advertisingId(); | ||
| if (validateResult(result)) | ||
| { | ||
| Ifa ifa = result.value(); | ||
| gOutput << "IFA: " << ifa.ifa << std::endl; | ||
| gOutput << "IFA Type: " << ifa.ifa_type << std::endl; | ||
| gOutput << "LMT: " << ifa.lmt << std::endl; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /** | ||
| * Copyright 2025 Comcast Cable Communications Management, LLC | ||
| * | ||
| * 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. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <string> | ||
| #include <vector> | ||
| #include "fireboltdemo.h" | ||
|
|
||
| class AdvertisingDemo : public IFireboltDemo | ||
| { | ||
| public: | ||
| AdvertisingDemo(); | ||
| ~AdvertisingDemo() = default; | ||
| void runOption(const int index); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cpp_test executable is being run without any arguments, but it appears to require a connection to a WebSocket server at ws://127.0.0.1:9998 (see main.cpp line 90). The test will likely fail because no mock server or actual server is set up in the CI environment. Consider either adding the -auto flag for automated testing, setting up a mock server, or handling connection failures gracefully in CI.