Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,6 @@ endif()
add_subdirectory(Core)
add_subdirectory(Polyfills)

if(JSRUNTIMEHOST_TESTS)
if(JSRUNTIMEHOST_TESTS AND NOT WINDOWS_STORE)
add_subdirectory(Tests)
endif()
22 changes: 0 additions & 22 deletions Tests/UnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,6 @@ if(APPLE)
set(SOURCES ${SOURCES}
macOS/App.mm)
endif()
elseif(WINDOWS_STORE)
set(APPX_FILES "UWP/Package.appxmanifest" "UWP/TemporaryKey.pfx")
set_property(SOURCE ${APPX_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1)
set(APPX_ASSETS
"UWP/Assets/LockScreenLogo.scale-200.png"
"UWP/Assets/SplashScreen.scale-200.png"
"UWP/Assets/Square44x44Logo.scale-200.png"
"UWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.png"
"UWP/Assets/Square150x150Logo.scale-200.png"
"UWP/Assets/StoreLogo.png"
"UWP/Assets/Wide310x150Logo.scale-200.png")
set_property(SOURCE ${APPX_ASSETS} PROPERTY VS_DEPLOYMENT_CONTENT 1)
set_property(SOURCE ${APPX_ASSETS} PROPERTY VS_DEPLOYMENT_LOCATION "Assets")
set(SOURCES ${SOURCES}
${APPX_FILES}
${APPX_ASSETS}
UWP/App.cpp)
elseif(WIN32)
set(SOURCES ${SOURCES}
Win32/App.cpp)
Expand All @@ -58,11 +41,6 @@ endif()
add_executable(UnitTests ${SOURCES} ${SCRIPTS} ${EXTERNAL_SCRIPTS})
target_compile_definitions(UnitTests PRIVATE JSRUNTIMEHOST_PLATFORM="${JSRUNTIMEHOST_PLATFORM}")

if(WINDOWS_STORE)
target_compile_options(UnitTests PRIVATE /ZW)
target_compile_options(UnitTests PRIVATE /await)
endif()

target_link_libraries(UnitTests
PRIVATE AppRuntime
PRIVATE Console
Expand Down
43 changes: 24 additions & 19 deletions Tests/UnitTests/Shared/Shared.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
#include "Shared.h"
#include <Babylon/AppRuntime.h>
#include <Babylon/ScriptLoader.h>
#include <Babylon/Polyfills/AbortController.h>
#include <Babylon/Polyfills/Console.h>
#include <Babylon/Polyfills/Scheduling.h>
#include <Babylon/Polyfills/XMLHttpRequest.h>
#include <Babylon/Polyfills/URL.h>
#include <Babylon/Polyfills/AbortController.h>
#include <Babylon/Polyfills/WebSocket.h>
#include <Babylon/Polyfills/XMLHttpRequest.h>
#include <gtest/gtest.h>
#include <future>
#include <iostream>

const char* EnumToString(Babylon::Polyfills::Console::LogLevel logLevel)
namespace
{
switch (logLevel)
const char* EnumToString(Babylon::Polyfills::Console::LogLevel logLevel)
{
case Babylon::Polyfills::Console::LogLevel::Log:
return "log";
case Babylon::Polyfills::Console::LogLevel::Warn:
return "warn";
case Babylon::Polyfills::Console::LogLevel::Error:
return "error";
switch (logLevel)
{
case Babylon::Polyfills::Console::LogLevel::Log:
return "log";
case Babylon::Polyfills::Console::LogLevel::Warn:
return "warn";
case Babylon::Polyfills::Console::LogLevel::Error:
return "error";
}

return "unknown";
}

return "unknown";
}

TEST(JavaScript, All)
Expand Down Expand Up @@ -61,11 +65,13 @@ TEST(JavaScript, All)
Babylon::Polyfills::WebSocket::Initialize(env);
Babylon::Polyfills::XMLHttpRequest::Initialize(env);

env.Global().Set("setExitCode", Napi::Function::New(env, [&exitCodePromise](const Napi::CallbackInfo& info)
{
Napi::Env env = info.Env();
exitCodePromise.set_value(info[0].As<Napi::Number>().Int32Value());
}, "setExitCode"));
auto setExitCodeCallback = Napi::Function::New(
env, [&exitCodePromise](const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
exitCodePromise.set_value(info[0].As<Napi::Number>().Int32Value());
},
"setExitCode");
env.Global().Set("setExitCode", setExitCodeCallback);

env.Global().Set("hostPlatform", Napi::Value::From(env, JSRUNTIMEHOST_PLATFORM));
});
Expand All @@ -87,8 +93,7 @@ TEST(Console, Log)
Babylon::AppRuntime runtime{};

runtime.Dispatch([](Napi::Env env) mutable {
Babylon::Polyfills::Console::Initialize(env, [](const char* message, Babylon::Polyfills::Console::LogLevel logLevel)
{
Babylon::Polyfills::Console::Initialize(env, [](const char* message, Babylon::Polyfills::Console::LogLevel logLevel) {
const char* test = "foo bar";
if (strcmp(message, test) != 0)
{
Expand Down
4 changes: 0 additions & 4 deletions Tests/UnitTests/Shared/Shared.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#pragma once

#include <Babylon/Polyfills/Console.h>

const char* EnumToString(Babylon::Polyfills::Console::LogLevel logLevel);

int RunTests();
8 changes: 0 additions & 8 deletions Tests/UnitTests/UWP/App.cpp

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Tests/UnitTests/UWP/Assets/StoreLogo.png
Binary file not shown.
Binary file not shown.
41 changes: 0 additions & 41 deletions Tests/UnitTests/UWP/Package.appxmanifest

This file was deleted.

Binary file removed Tests/UnitTests/UWP/TemporaryKey.pfx
Binary file not shown.
3 changes: 3 additions & 0 deletions Tests/UnitTests/Win32/App.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "../Shared/Shared.h"
#include <Windows.h>

int main()
{
SetConsoleOutputCP(CP_UTF8);

return RunTests();
}
4 changes: 3 additions & 1 deletion Tests/UnitTests/iOS/App.mm
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#include "../Shared/Shared.h"
#include <iostream>

int main()
{
int exitCode = RunTests();

// CI will pick up the exit code from stderr when running in the iOS Simulator.
fprintf(stderr, "%i\n", exitCode);
std::cerr << exitCode << std::endl;
std::cerr.flush();

return exitCode;
}