|
32 | 32 | #include "flutter/shell/common/vsync_waiter_fallback.h" |
33 | 33 | #include "flutter/shell/version/version.h" |
34 | 34 | #include "flutter/testing/testing.h" |
35 | | -#include "rapidjson/writer.h" |
| 35 | +#include "third_party/rapidjson/include/rapidjson/writer.h" |
36 | 36 | #include "third_party/skia/include/core/SkPictureRecorder.h" |
37 | 37 | #include "third_party/tonic/converter/dart_converter.h" |
38 | 38 |
|
| 39 | +#ifdef SHELL_ENABLE_VULKAN |
| 40 | +#include "flutter/vulkan/vulkan_application.h" // nogncheck |
| 41 | +#endif |
| 42 | + |
39 | 43 | namespace flutter { |
40 | 44 | namespace testing { |
41 | 45 |
|
@@ -576,16 +580,16 @@ TEST_F(ShellTest, ReportTimingsIsCalledSoonerInNonReleaseMode) { |
576 | 580 | DestroyShell(std::move(shell)); |
577 | 581 |
|
578 | 582 | fml::TimePoint finish = fml::TimePoint::Now(); |
579 | | - fml::TimeDelta ellapsed = finish - start; |
| 583 | + fml::TimeDelta elapsed = finish - start; |
580 | 584 |
|
581 | 585 | #if FLUTTER_RELEASE |
582 | 586 | // Our batch time is 1000ms. Hopefully the 800ms limit is relaxed enough to |
583 | 587 | // make it not too flaky. |
584 | | - ASSERT_TRUE(ellapsed >= fml::TimeDelta::FromMilliseconds(800)); |
| 588 | + ASSERT_TRUE(elapsed >= fml::TimeDelta::FromMilliseconds(800)); |
585 | 589 | #else |
586 | 590 | // Our batch time is 100ms. Hopefully the 500ms limit is relaxed enough to |
587 | 591 | // make it not too flaky. |
588 | | - ASSERT_TRUE(ellapsed <= fml::TimeDelta::FromMilliseconds(500)); |
| 592 | + ASSERT_TRUE(elapsed <= fml::TimeDelta::FromMilliseconds(500)); |
589 | 593 | #endif |
590 | 594 | } |
591 | 595 |
|
@@ -797,8 +801,15 @@ TEST_F(ShellTest, SetResourceCacheSize) { |
797 | 801 | RunEngine(shell.get(), std::move(configuration)); |
798 | 802 | PumpOneFrame(shell.get()); |
799 | 803 |
|
| 804 | + // The Vulkan and GL backends set different default values for the resource |
| 805 | + // cache size. |
| 806 | +#ifdef SHELL_ENABLE_VULKAN |
| 807 | + EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell), |
| 808 | + vulkan::kGrCacheMaxByteSize); |
| 809 | +#else |
800 | 810 | EXPECT_EQ(GetRasterizerResourceCacheBytesSync(*shell), |
801 | 811 | static_cast<size_t>(24 * (1 << 20))); |
| 812 | +#endif |
802 | 813 |
|
803 | 814 | fml::TaskRunner::RunNowOrPostTask( |
804 | 815 | shell->GetTaskRunners().GetPlatformTaskRunner(), [&shell]() { |
@@ -1231,15 +1242,17 @@ TEST_F(ShellTest, CanDecompressImageFromAsset) { |
1231 | 1242 | } |
1232 | 1243 |
|
1233 | 1244 | TEST_F(ShellTest, OnServiceProtocolGetSkSLsWorks) { |
| 1245 | + fml::ScopedTemporaryDirectory base_dir; |
| 1246 | + ASSERT_TRUE(base_dir.fd().is_valid()); |
| 1247 | + PersistentCache::SetCacheDirectoryPath(base_dir.path()); |
| 1248 | + PersistentCache::ResetCacheForProcess(); |
| 1249 | + |
1234 | 1250 | // Create 2 dummy SkSL cache file IE (base32 encoding of A), II (base32 |
1235 | 1251 | // encoding of B) with content x and y. |
1236 | | - fml::ScopedTemporaryDirectory temp_dir; |
1237 | | - PersistentCache::SetCacheDirectoryPath(temp_dir.path()); |
1238 | | - PersistentCache::ResetCacheForProcess(); |
1239 | | - std::vector<std::string> components = {"flutter_engine", |
1240 | | - GetFlutterEngineVersion(), "skia", |
1241 | | - GetSkiaVersion(), "sksl"}; |
1242 | | - auto sksl_dir = fml::CreateDirectory(temp_dir.fd(), components, |
| 1252 | + std::vector<std::string> components = { |
| 1253 | + "flutter_engine", GetFlutterEngineVersion(), "skia", GetSkiaVersion(), |
| 1254 | + PersistentCache::kSkSLSubdirName}; |
| 1255 | + auto sksl_dir = fml::CreateDirectory(base_dir.fd(), components, |
1243 | 1256 | fml::FilePermission::kReadWrite); |
1244 | 1257 | const std::string x = "x"; |
1245 | 1258 | const std::string y = "y"; |
@@ -1270,9 +1283,6 @@ TEST_F(ShellTest, OnServiceProtocolGetSkSLsWorks) { |
1270 | 1283 | (expected_json2 == buffer.GetString()); |
1271 | 1284 | ASSERT_TRUE(json_is_expected) << buffer.GetString() << " is not equal to " |
1272 | 1285 | << expected_json1 << " or " << expected_json2; |
1273 | | - |
1274 | | - // Cleanup files |
1275 | | - fml::RemoveFilesInDirectory(temp_dir.fd()); |
1276 | 1286 | } |
1277 | 1287 |
|
1278 | 1288 | TEST_F(ShellTest, RasterizerScreenshot) { |
|
0 commit comments