mirror of
https://github.com/vczh-libraries/Release.git
synced 2026-05-21 22:51:26 +08:00
Update import
This commit is contained in:
@@ -87,6 +87,11 @@ IGuiRemoteProtocolMessages (Rendering)
|
||||
#undef ERROR_MESSAGE_PREFIX
|
||||
}
|
||||
|
||||
void UnitTestRemoteProtocol_Rendering::Impl_RendererIdle()
|
||||
{
|
||||
rendererIdleCount++;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
IGuiRemoteProtocolMessages (Rendering - Element)
|
||||
***********************************************************************/
|
||||
@@ -1806,7 +1811,7 @@ File GacUIUnitTest_PrepareSnapshotFile(const WString& appName, const WString& ex
|
||||
|
||||
File snapshotFile = snapshotFolder.GetFilePath() / (appName + extension);
|
||||
{
|
||||
auto pathPrefix = snapshotFolder.GetFilePath().GetFullPath() + WString::FromChar(FilePath::Delimiter);
|
||||
auto pathPrefix = snapshotFolder.GetFilePath().GetFullPath() + WString::FromChar(FilePath::GetPathDelimiter());
|
||||
auto snapshotPath = snapshotFile.GetFilePath().GetFullPath();
|
||||
CHECK_ERROR(
|
||||
snapshotPath.Length() > pathPrefix.Length() && snapshotPath.Left(pathPrefix.Length()) == pathPrefix,
|
||||
|
||||
@@ -791,6 +791,7 @@ UnitTestRemoteProtocol
|
||||
remoteprotocol::DomIndex receivedDomIndex;
|
||||
bool receivedDomDiffMessage = false;
|
||||
bool receivedElementMessage = false;
|
||||
vint rendererIdleCount = 0;
|
||||
|
||||
ElementDescMap lastElementDescs;
|
||||
IdSet removedElementIds;
|
||||
@@ -828,6 +829,7 @@ IGuiRemoteProtocolMessages (Rendering)
|
||||
Ptr<UnitTestLoggedFrame> TryGetLastRenderingFrameAndReset();
|
||||
void Impl_RendererBeginRendering(const remoteprotocol::ElementBeginRendering& arguments);
|
||||
void Impl_RendererEndRendering(vint id);
|
||||
void Impl_RendererIdle();
|
||||
|
||||
/***********************************************************************
|
||||
IGuiRemoteProtocolMessages (Rendering - Element)
|
||||
@@ -1105,6 +1107,17 @@ IGuiRemoteProtocol
|
||||
auto&& lastFrame = (*loggedTrace.frames.Obj())[loggedTrace.frames->Count() - 1];
|
||||
lastFrame.frameName = name;
|
||||
}
|
||||
if (nextEventIndex == 0)
|
||||
{
|
||||
CHECK_ERROR(rendererIdleCount <= 1, ERROR_MESSAGE_PREFIX L"Expected at most one RendererIdle before the first frame boundary.");
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECK_ERROR(rendererIdleCount == 1, ERROR_MESSAGE_PREFIX L"Expected exactly one RendererIdle between two frame boundaries.");
|
||||
}
|
||||
rendererIdleCount = 0;
|
||||
// Note: do not reset rendererIdleCount when LogRenderingResult() is false;
|
||||
// it must accumulate across non-boundary ticks to detect duplicate/out-of-order RendererIdle.
|
||||
frameExecuting = true;
|
||||
func();
|
||||
frameExecuting = false;
|
||||
@@ -1123,6 +1136,7 @@ IGuiRemoteProtocol
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
.\GUIUNITTESTUTILITIES.H
|
||||
***********************************************************************/
|
||||
|
||||
+460
-344
File diff suppressed because it is too large
Load Diff
+107
-79
File diff suppressed because it is too large
Load Diff
@@ -2526,7 +2526,7 @@ Type Declaration (Class)
|
||||
|
||||
CLASS_MEMBER_PROPERTY_READONLY_FAST(ViewSize)
|
||||
CLASS_MEMBER_PROPERTY_READONLY_FAST(ViewBounds)
|
||||
CLASS_MEMBER_PROPERTY_READONLY_FAST(ViewPosition)
|
||||
CLASS_MEMBER_PROPERTY_FAST(ViewPosition)
|
||||
CLASS_MEMBER_PROPERTY_READONLY_FAST(HorizontalScroll)
|
||||
CLASS_MEMBER_PROPERTY_READONLY_FAST(VerticalScroll)
|
||||
CLASS_MEMBER_PROPERTY_FAST(HorizontalAlwaysVisible)
|
||||
|
||||
@@ -3027,6 +3027,12 @@
|
||||
"name": "ElementMeasurings"
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"$ast": "MessageDecl",
|
||||
"attributes": [],
|
||||
"name": "RendererIdle",
|
||||
"request": null,
|
||||
"response": null
|
||||
}, {
|
||||
"$ast": "StructDecl",
|
||||
"attributes": [],
|
||||
|
||||
@@ -91,3 +91,4 @@ message RendererBeginBoundary { request: ElementBoundary;
|
||||
message RendererRenderElement { request: ElementRendering; }
|
||||
message RendererEndBoundary {}
|
||||
message RendererEndRendering { response: ElementMeasurings; }
|
||||
message RendererIdle {}
|
||||
|
||||
+25
-4
@@ -41,6 +41,27 @@ LinuxFileSystemImpl
|
||||
{
|
||||
public:
|
||||
// FilePath operations implementation
|
||||
wchar_t GetPathDelimiter() const override
|
||||
{
|
||||
return L'/';
|
||||
}
|
||||
|
||||
const wchar_t* GetCompatibleDelimiters() const override
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
|
||||
WString ConcatPath(const WString& fullPath, const WString& relativePath) const override
|
||||
{
|
||||
auto delimiter = WString::FromChar(GetPathDelimiter());
|
||||
if (IsRoot(fullPath))
|
||||
{
|
||||
return delimiter + relativePath;
|
||||
}
|
||||
|
||||
return fullPath + delimiter + relativePath;
|
||||
}
|
||||
|
||||
void Initialize(WString& fullPath) const override
|
||||
{
|
||||
{
|
||||
@@ -51,13 +72,13 @@ LinuxFileSystemImpl
|
||||
}
|
||||
|
||||
if (fullPath.Length() == 0)
|
||||
fullPath = WString::Unmanaged(L"/");
|
||||
fullPath = WString::FromChar(GetPathDelimiter());
|
||||
|
||||
if (fullPath[0] != FilePath::Delimiter)
|
||||
if (fullPath[0] != GetPathDelimiter())
|
||||
{
|
||||
char buffer[PATH_MAX] = { 0 };
|
||||
getcwd(buffer, PATH_MAX);
|
||||
fullPath = atow(AString(buffer)) + WString::FromChar(FilePath::Delimiter) + fullPath;
|
||||
fullPath = atow(AString(buffer)) + WString::FromChar(GetPathDelimiter()) + fullPath;
|
||||
}
|
||||
|
||||
{
|
||||
@@ -111,7 +132,7 @@ LinuxFileSystemImpl
|
||||
|
||||
bool IsRoot(const WString& fullPath) const override
|
||||
{
|
||||
return fullPath == L"/";
|
||||
return fullPath == WString::FromChar(GetPathDelimiter());
|
||||
}
|
||||
|
||||
WString GetRelativePathFor(const WString& fromPath, const WString& toPath) const override
|
||||
|
||||
@@ -41,6 +41,26 @@ WindowsFileSystemImpl
|
||||
class WindowsFileSystemImpl : public feature_injection::FeatureImpl<IFileSystemImpl>
|
||||
{
|
||||
public:
|
||||
wchar_t GetPathDelimiter() const override
|
||||
{
|
||||
return L'\\';
|
||||
}
|
||||
|
||||
const wchar_t* GetCompatibleDelimiters() const override
|
||||
{
|
||||
return L"/";
|
||||
}
|
||||
|
||||
WString ConcatPath(const WString& fullPath, const WString& relativePath) const override
|
||||
{
|
||||
if (IsRoot(fullPath))
|
||||
{
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
return fullPath + WString::FromChar(GetPathDelimiter()) + relativePath;
|
||||
}
|
||||
|
||||
void Initialize(WString& fullPath) const override
|
||||
{
|
||||
{
|
||||
|
||||
+66
-50
@@ -20,6 +20,18 @@ namespace vl
|
||||
using namespace collections;
|
||||
using namespace stream;
|
||||
|
||||
extern IFileSystemImpl* GetFileSystemImpl();
|
||||
|
||||
static wchar_t GetInjectedDelimiter()
|
||||
{
|
||||
return GetFileSystemImpl()->GetPathDelimiter();
|
||||
}
|
||||
|
||||
static WString GetInjectedDelimiterString()
|
||||
{
|
||||
return WString::FromChar(GetInjectedDelimiter());
|
||||
}
|
||||
|
||||
// ReadDirectoryChangesW
|
||||
|
||||
/***********************************************************************
|
||||
@@ -28,18 +40,25 @@ FilePath
|
||||
|
||||
void FilePath::NormalizeDelimiters(collections::Array<wchar_t>& buffer)
|
||||
{
|
||||
auto delimiter = GetInjectedDelimiter();
|
||||
auto compatibleDelimiters = GetFileSystemImpl()->GetCompatibleDelimiters();
|
||||
for (vint i = 0; i < buffer.Count(); i++)
|
||||
{
|
||||
if (buffer[i] == L'\\' || buffer[i] == L'/')
|
||||
for (auto reading = compatibleDelimiters; *reading; reading++)
|
||||
{
|
||||
buffer[i] = Delimiter;
|
||||
if (*reading == buffer[i])
|
||||
{
|
||||
buffer[i] = delimiter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FilePath::TrimLastDelimiter(WString& fullPath)
|
||||
{
|
||||
if (fullPath != L"/" && fullPath.Length() > 0 && fullPath[fullPath.Length() - 1] == Delimiter)
|
||||
auto delimiter = GetInjectedDelimiter();
|
||||
if (!GetFileSystemImpl()->IsRoot(fullPath) && fullPath.Length() > 0 && fullPath[fullPath.Length() - 1] == delimiter)
|
||||
{
|
||||
fullPath = fullPath.Left(fullPath.Length() - 1);
|
||||
}
|
||||
@@ -67,21 +86,9 @@ FilePath
|
||||
{
|
||||
}
|
||||
|
||||
FilePath FilePath::operator/(const WString& relativePath)const
|
||||
{
|
||||
if (IsRoot())
|
||||
{
|
||||
return relativePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return fullPath + L"/" + relativePath;
|
||||
}
|
||||
}
|
||||
|
||||
WString FilePath::GetName()const
|
||||
{
|
||||
auto delimiter = WString::FromChar(Delimiter);
|
||||
auto delimiter = GetInjectedDelimiterString();
|
||||
auto index = INVLOC.FindLast(fullPath, delimiter, Locale::None);
|
||||
if (index.key == -1) return fullPath;
|
||||
return fullPath.Right(fullPath.Length() - index.key - 1);
|
||||
@@ -89,7 +96,7 @@ FilePath
|
||||
|
||||
FilePath FilePath::GetFolder()const
|
||||
{
|
||||
auto delimiter = WString::FromChar(Delimiter);
|
||||
auto delimiter = GetInjectedDelimiterString();
|
||||
auto index = INVLOC.FindLast(fullPath, delimiter, Locale::None);
|
||||
if (index.key == -1) return FilePath();
|
||||
return fullPath.Left(index.key);
|
||||
@@ -103,13 +110,15 @@ FilePath
|
||||
void FilePath::GetPathComponents(WString path, collections::List<WString>& components)
|
||||
{
|
||||
WString pathRemaining = path;
|
||||
auto delimiter = WString::FromChar(Delimiter);
|
||||
auto delimiter = GetInjectedDelimiter();
|
||||
auto delimiterString = WString::FromChar(delimiter);
|
||||
auto doubleDelimiter = delimiterString + delimiterString;
|
||||
|
||||
components.Clear();
|
||||
|
||||
while (true)
|
||||
{
|
||||
auto index = INVLOC.FindFirst(pathRemaining, delimiter, Locale::None);
|
||||
auto index = INVLOC.FindFirst(pathRemaining, delimiterString, Locale::None);
|
||||
if (index.key == -1)
|
||||
break;
|
||||
|
||||
@@ -117,19 +126,15 @@ FilePath
|
||||
components.Add(pathRemaining.Left(index.key));
|
||||
else
|
||||
{
|
||||
#if defined VCZH_MSVC
|
||||
if (pathRemaining.Length() >= 2 && pathRemaining[1] == Delimiter)
|
||||
if (pathRemaining.Length() >= 2 && pathRemaining[1] == delimiter)
|
||||
{
|
||||
// Windows UNC Path starting with "\\"
|
||||
// components[0] will be L"\\"
|
||||
components.Add(L"\\");
|
||||
components.Add(doubleDelimiter);
|
||||
index.value++;
|
||||
}
|
||||
#elif defined VCZH_GCC
|
||||
// Unix absolute path starting with "/"
|
||||
// components[0] will be L"/"
|
||||
components.Add(delimiter);
|
||||
#endif
|
||||
else if (GetFileSystemImpl()->IsRoot(delimiterString))
|
||||
{
|
||||
components.Add(delimiterString);
|
||||
}
|
||||
}
|
||||
|
||||
pathRemaining = pathRemaining.Right(pathRemaining.Length() - (index.key + index.value));
|
||||
@@ -144,31 +149,32 @@ FilePath
|
||||
WString FilePath::ComponentsToPath(const collections::List<WString>& components)
|
||||
{
|
||||
WString result;
|
||||
auto delimiter = WString::FromChar(Delimiter);
|
||||
auto delimiter = GetInjectedDelimiterString();
|
||||
auto doubleDelimiter = delimiter + delimiter;
|
||||
|
||||
int i = 0;
|
||||
|
||||
#if defined VCZH_MSVC
|
||||
// For Windows, if first component is "\\" then it is an UNC path
|
||||
if(components.Count() > 0 && components[0] == L"\\")
|
||||
{
|
||||
result += delimiter;
|
||||
i++;
|
||||
}
|
||||
#elif defined VCZH_GCC
|
||||
// For Unix-like OSes, if first component is "/" then take it as absolute path
|
||||
if(components.Count() > 0 && components[0] == delimiter)
|
||||
{
|
||||
result += delimiter;
|
||||
i++;
|
||||
}
|
||||
#endif
|
||||
vint i = 0;
|
||||
|
||||
for(; i < components.Count(); i++)
|
||||
if (components.Count() > 0)
|
||||
{
|
||||
result += components[i];
|
||||
if(i + 1 < components.Count())
|
||||
if (components[0] == doubleDelimiter)
|
||||
{
|
||||
result += doubleDelimiter;
|
||||
i++;
|
||||
}
|
||||
else if (components[0] == delimiter)
|
||||
{
|
||||
result += delimiter;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
for (; i < components.Count(); i++)
|
||||
{
|
||||
if (result.Length() > 0 && result[result.Length() - 1] != GetInjectedDelimiter())
|
||||
{
|
||||
result += delimiter;
|
||||
}
|
||||
result += components[i];
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -475,11 +481,21 @@ namespace vl
|
||||
FilePath
|
||||
***********************************************************************/
|
||||
|
||||
wchar_t FilePath::GetPathDelimiter()
|
||||
{
|
||||
return GetFileSystemImpl()->GetPathDelimiter();
|
||||
}
|
||||
|
||||
void FilePath::Initialize()
|
||||
{
|
||||
GetFileSystemImpl()->Initialize(fullPath);
|
||||
}
|
||||
|
||||
FilePath FilePath::operator/(const WString& relativePath) const
|
||||
{
|
||||
return GetFileSystemImpl()->ConcatPath(fullPath, relativePath);
|
||||
}
|
||||
|
||||
bool FilePath::IsFile() const
|
||||
{
|
||||
return GetFileSystemImpl()->IsFile(fullPath);
|
||||
|
||||
+5
-11
@@ -2488,17 +2488,8 @@ namespace vl
|
||||
static void GetPathComponents(WString path, collections::List<WString>& components);
|
||||
static WString ComponentsToPath(const collections::List<WString>& components);
|
||||
public:
|
||||
#if defined VCZH_MSVC
|
||||
/// <summary>The delimiter character used in a file path</summary>
|
||||
/// <remarks>
|
||||
/// In Windows, it is "\".
|
||||
/// In Linux and macOS, it is "/".
|
||||
/// But you can always use "/", it is also supported in Windows.
|
||||
/// </remarks>
|
||||
static constexpr wchar_t Delimiter = L'\\';
|
||||
#elif defined VCZH_GCC
|
||||
static constexpr wchar_t Delimiter = L'/';
|
||||
#endif
|
||||
/// <summary>Get the delimiter character used in a file path.</summary>
|
||||
static wchar_t GetPathDelimiter();
|
||||
|
||||
/// <summary>Create a root path.</summary>
|
||||
/// <remarks><see cref="GetFullPath"/> returns different values for root path on different platforms. Do not rely on the value.</remarks>
|
||||
@@ -2675,6 +2666,9 @@ namespace vl
|
||||
{
|
||||
public:
|
||||
// FilePath operations
|
||||
virtual wchar_t GetPathDelimiter() const = 0;
|
||||
virtual const wchar_t* GetCompatibleDelimiters() const = 0;
|
||||
virtual WString ConcatPath(const WString& fullPath, const WString& relativePath) const = 0;
|
||||
virtual void Initialize(WString& fullPath) const = 0;
|
||||
virtual bool IsFile(const WString& fullPath) const = 0;
|
||||
virtual bool IsFolder(const WString& fullPath) const = 0;
|
||||
|
||||
Reference in New Issue
Block a user