Skip to content

Commit ef3bb85

Browse files
authored
Minor fixes (#85)
- Remove UWP tests to avoid confusion since they don't work - Clean up the shared test code a bit - Add SetConsoleOutputCP to Win32 test to get Unicode console output
1 parent 5f20827 commit ef3bb85

16 files changed

+31
-96
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,6 @@ endif()
128128
add_subdirectory(Core)
129129
add_subdirectory(Polyfills)
130130

131-
if(JSRUNTIMEHOST_TESTS)
131+
if(JSRUNTIMEHOST_TESTS AND NOT WINDOWS_STORE)
132132
add_subdirectory(Tests)
133133
endif()

Tests/UnitTests/CMakeLists.txt

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,6 @@ if(APPLE)
3030
set(SOURCES ${SOURCES}
3131
macOS/App.mm)
3232
endif()
33-
elseif(WINDOWS_STORE)
34-
set(APPX_FILES "UWP/Package.appxmanifest" "UWP/TemporaryKey.pfx")
35-
set_property(SOURCE ${APPX_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1)
36-
set(APPX_ASSETS
37-
"UWP/Assets/LockScreenLogo.scale-200.png"
38-
"UWP/Assets/SplashScreen.scale-200.png"
39-
"UWP/Assets/Square44x44Logo.scale-200.png"
40-
"UWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.png"
41-
"UWP/Assets/Square150x150Logo.scale-200.png"
42-
"UWP/Assets/StoreLogo.png"
43-
"UWP/Assets/Wide310x150Logo.scale-200.png")
44-
set_property(SOURCE ${APPX_ASSETS} PROPERTY VS_DEPLOYMENT_CONTENT 1)
45-
set_property(SOURCE ${APPX_ASSETS} PROPERTY VS_DEPLOYMENT_LOCATION "Assets")
46-
set(SOURCES ${SOURCES}
47-
${APPX_FILES}
48-
${APPX_ASSETS}
49-
UWP/App.cpp)
5033
elseif(WIN32)
5134
set(SOURCES ${SOURCES}
5235
Win32/App.cpp)
@@ -58,11 +41,6 @@ endif()
5841
add_executable(UnitTests ${SOURCES} ${SCRIPTS} ${EXTERNAL_SCRIPTS})
5942
target_compile_definitions(UnitTests PRIVATE JSRUNTIMEHOST_PLATFORM="${JSRUNTIMEHOST_PLATFORM}")
6043

61-
if(WINDOWS_STORE)
62-
target_compile_options(UnitTests PRIVATE /ZW)
63-
target_compile_options(UnitTests PRIVATE /await)
64-
endif()
65-
6644
target_link_libraries(UnitTests
6745
PRIVATE AppRuntime
6846
PRIVATE Console

Tests/UnitTests/Shared/Shared.cpp

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
#include "Shared.h"
22
#include <Babylon/AppRuntime.h>
33
#include <Babylon/ScriptLoader.h>
4+
#include <Babylon/Polyfills/AbortController.h>
5+
#include <Babylon/Polyfills/Console.h>
46
#include <Babylon/Polyfills/Scheduling.h>
5-
#include <Babylon/Polyfills/XMLHttpRequest.h>
67
#include <Babylon/Polyfills/URL.h>
7-
#include <Babylon/Polyfills/AbortController.h>
88
#include <Babylon/Polyfills/WebSocket.h>
9+
#include <Babylon/Polyfills/XMLHttpRequest.h>
910
#include <gtest/gtest.h>
1011
#include <future>
1112
#include <iostream>
1213

13-
const char* EnumToString(Babylon::Polyfills::Console::LogLevel logLevel)
14+
namespace
1415
{
15-
switch (logLevel)
16+
const char* EnumToString(Babylon::Polyfills::Console::LogLevel logLevel)
1617
{
17-
case Babylon::Polyfills::Console::LogLevel::Log:
18-
return "log";
19-
case Babylon::Polyfills::Console::LogLevel::Warn:
20-
return "warn";
21-
case Babylon::Polyfills::Console::LogLevel::Error:
22-
return "error";
18+
switch (logLevel)
19+
{
20+
case Babylon::Polyfills::Console::LogLevel::Log:
21+
return "log";
22+
case Babylon::Polyfills::Console::LogLevel::Warn:
23+
return "warn";
24+
case Babylon::Polyfills::Console::LogLevel::Error:
25+
return "error";
26+
}
27+
28+
return "unknown";
2329
}
24-
25-
return "unknown";
2630
}
2731

2832
TEST(JavaScript, All)
@@ -61,11 +65,13 @@ TEST(JavaScript, All)
6165
Babylon::Polyfills::WebSocket::Initialize(env);
6266
Babylon::Polyfills::XMLHttpRequest::Initialize(env);
6367

64-
env.Global().Set("setExitCode", Napi::Function::New(env, [&exitCodePromise](const Napi::CallbackInfo& info)
65-
{
66-
Napi::Env env = info.Env();
67-
exitCodePromise.set_value(info[0].As<Napi::Number>().Int32Value());
68-
}, "setExitCode"));
68+
auto setExitCodeCallback = Napi::Function::New(
69+
env, [&exitCodePromise](const Napi::CallbackInfo& info) {
70+
Napi::Env env = info.Env();
71+
exitCodePromise.set_value(info[0].As<Napi::Number>().Int32Value());
72+
},
73+
"setExitCode");
74+
env.Global().Set("setExitCode", setExitCodeCallback);
6975

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

8995
runtime.Dispatch([](Napi::Env env) mutable {
90-
Babylon::Polyfills::Console::Initialize(env, [](const char* message, Babylon::Polyfills::Console::LogLevel logLevel)
91-
{
96+
Babylon::Polyfills::Console::Initialize(env, [](const char* message, Babylon::Polyfills::Console::LogLevel logLevel) {
9297
const char* test = "foo bar";
9398
if (strcmp(message, test) != 0)
9499
{

Tests/UnitTests/Shared/Shared.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
#pragma once
22

3-
#include <Babylon/Polyfills/Console.h>
4-
5-
const char* EnumToString(Babylon::Polyfills::Console::LogLevel logLevel);
6-
73
int RunTests();

Tests/UnitTests/UWP/App.cpp

Lines changed: 0 additions & 8 deletions
This file was deleted.
-1.4 KB
Binary file not shown.
-7.52 KB
Binary file not shown.
-2.87 KB
Binary file not shown.
-1.61 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)