Commit bcf96e4c authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

[ios] Fix DIR_SOURCE_ROOT for EarlGrey2 tests

On iOS, the application has no access to source_root directly as
all applications are bundled. Thus the test data are bundled as
asserts and need to be located in DIR_ASSETS.

For most of the tests, the directory containing the app binary
is the directory containing the assets, but this is not the case
for EarlGrey2 test that are part of a PlugIns bundle.

Using DIR_ASSETS instead loads the correct path since it is
relative to the code that is running, not to the main application.

Bug: none
Change-Id: I25b0c7b9ac8a7686332591f4488440ffb7f5d4c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2149427
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759233}
parent ec943409
...@@ -82,6 +82,11 @@ bool PathProviderMac(int key, base::FilePath* result) { ...@@ -82,6 +82,11 @@ bool PathProviderMac(int key, base::FilePath* result) {
return success; return success;
} }
case base::DIR_SOURCE_ROOT: case base::DIR_SOURCE_ROOT:
#if defined(OS_IOS)
// On iOS, there is no access to source root, however, the necessary
// resources are packaged into the test as assets.
return PathService::Get(base::DIR_ASSETS, result);
#else
// Go through PathService to catch overrides. // Go through PathService to catch overrides.
if (!PathService::Get(base::FILE_EXE, result)) if (!PathService::Get(base::FILE_EXE, result))
return false; return false;
...@@ -89,7 +94,6 @@ bool PathProviderMac(int key, base::FilePath* result) { ...@@ -89,7 +94,6 @@ bool PathProviderMac(int key, base::FilePath* result) {
// Start with the executable's directory. // Start with the executable's directory.
*result = result->DirName(); *result = result->DirName();
#if !defined(OS_IOS)
if (base::mac::AmIBundled()) { if (base::mac::AmIBundled()) {
// The bundled app executables (Chromium, TestShell, etc) live five // The bundled app executables (Chromium, TestShell, etc) live five
// levels down, eg: // levels down, eg:
...@@ -100,7 +104,7 @@ bool PathProviderMac(int key, base::FilePath* result) { ...@@ -100,7 +104,7 @@ bool PathProviderMac(int key, base::FilePath* result) {
// src/xcodebuild/{Debug|Release}/base_unittests // src/xcodebuild/{Debug|Release}/base_unittests
*result = result->DirName().DirName(); *result = result->DirName().DirName();
} }
#endif #endif // !defined(OS_IOS)
return true; return true;
case base::DIR_USER_DESKTOP: case base::DIR_USER_DESKTOP:
#if defined(OS_IOS) #if defined(OS_IOS)
...@@ -112,7 +116,7 @@ bool PathProviderMac(int key, base::FilePath* result) { ...@@ -112,7 +116,7 @@ bool PathProviderMac(int key, base::FilePath* result) {
#endif #endif
case base::DIR_ASSETS: case base::DIR_ASSETS:
#if defined(OS_IOS) #if defined(OS_IOS)
// TODO(https://crbug.com/957792): Assets live alongside the executable. // On iOS, the assets are located next to the module binary.
return PathService::Get(base::DIR_MODULE, result); return PathService::Get(base::DIR_MODULE, result);
#else #else
if (!base::mac::AmIBundled()) { if (!base::mac::AmIBundled()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment