Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
vczh committed Feb 17, 2025
1 parent 9fa7a5b commit bfc3b85
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Source/PlatformProviders/Remote/GuiRemoteProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@ GacUI::Remote Window
#include "GuiRemoteProtocol_Filter.h"
#include "GuiRemoteProtocol_DomDiff.h"
#include "GuiRemoteProtocol_Channel_Json.h"
#include "GuiRemoteProtocol_Channel_Async.h"

namespace vl::presentation::remoteprotocol::channeling
{
using GuiRemoteProtocolAsyncJsonChannelSerializer = GuiRemoteProtocolAsyncChannelSerializer<Ptr<glr::json::JsonObject>>;
}

#endif
57 changes: 56 additions & 1 deletion Source/UnitTestUtilities/GuiUnitTestUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,62 @@ void GacUIUnitTest_Start(const WString& appName, Nullable<UnitTestScreenConfig>

void GacUIUnitTest_StartAsync(const WString& appName, Nullable<UnitTestScreenConfig> config)
{
CHECK_FAIL(L"Not Implemented!");
TEST_ASSERT(config && config.Value().useChannel == UnitTestRemoteChannel::Async);

// Renderer
UnitTestRemoteProtocol unitTestProtocol(appName, config.Value());
auto jsonParser = Ptr(new glr::json::Parser);

// Data Processing in Renderer
channeling::GuiRemoteJsonChannelFromProtocol channelReceiver(unitTestProtocol.GetProtocol());
channeling::GuiRemoteJsonChannelStringDeserializer channelJsonDeserializer(&channelReceiver, jsonParser);
channeling::GuiRemoteUtfStringChannelDeserializer<wchar_t, char8_t> channelUtf8Deserializer(&channelJsonDeserializer);

// Boundary between Binaries

// Data Processing in Core
channeling::GuiRemoteUtfStringChannelSerializer<wchar_t, char8_t> channelUtf8Serializer(&channelUtf8Deserializer);
channeling::GuiRemoteJsonChannelStringSerializer channelJsonSerializer(&channelUtf8Serializer, jsonParser);

// Boundary between threads

channeling::GuiRemoteProtocolAsyncJsonChannelSerializer asyncChannelSender;
asyncChannelSender.Start(
&channelJsonSerializer,
[&unitTestProtocol, config](channeling::GuiRemoteProtocolAsyncJsonChannelSerializer* channel)
{
channeling::GuiRemoteProtocolFromJsonChannel channelSender(channel);

// Core
repeatfiltering::GuiRemoteProtocolFilterVerifier verifierProtocol(&channelSender);
repeatfiltering::GuiRemoteProtocolFilter filteredProtocol(&verifierProtocol);
GuiRemoteProtocolDomDiffConverter diffConverterProtocol(&filteredProtocol);

UnitTestContextImpl unitTestContext(&unitTestProtocol);
guiMainUnitTestContext = &unitTestContext;
SetupRemoteNativeController(
config.Value().useDomDiff
? static_cast<IGuiRemoteProtocol*>(&diffConverterProtocol)
: &filteredProtocol
);
GacUIUnitTest_SetGuiMainProxy({});
},
[](
channeling::GuiRemoteProtocolAsyncJsonChannelSerializer::TChannelThreadProc channelThreadProc,
channeling::GuiRemoteProtocolAsyncJsonChannelSerializer::TUIThreadProc uiThreadProc
)
{
Thread::CreateAndStart(channelThreadProc);
Thread::CreateAndStart(uiThreadProc);
});

asyncChannelSender.WaitForStopped();
GacUIUnitTest_LogUI(appName, unitTestProtocol);
if (!config.Value().useDomDiff)
{
GacUIUnitTest_LogCommands(appName, unitTestProtocol);
}
GacUIUnitTest_LogDiffs(appName, unitTestProtocol);
}

void GacUIUnitTest_Start_WithResourceAsText(const WString& appName, Nullable<UnitTestScreenConfig> config, const WString& resourceText)
Expand Down
3 changes: 2 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
- [x] Unit test
- [ ] Binary channel
- [x] Json to `ObjectString<T>` channel conversion
- [ ] Sync to Async channel conversion
- [x] Sync to Async channel conversion
- [ ] Test sending disconnect or other events when `Submit()` is pending on the event.
- Remote protocol redirection back to native rendering:
- In the test project, C++ side will expose the remote protocol via dll.
- Use string first, and then change to binary.
Expand Down
8 changes: 8 additions & 0 deletions Test/GacUISrc/UnitTest/TestRemote_UnitTestFramework_Async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,13 @@ TEST_FILE
globalConfig
);
});

TEST_CASE(L"Exit on Half Way")
{
});

TEST_CASE(L"Disconnect and Reconnect")
{
});
});
}

0 comments on commit bfc3b85

Please sign in to comment.