Skip to content

Commit

Permalink
[vr] Add dummy assets for Chromium
Browse files Browse the repository at this point in the history
Chromium assets will be used for testing in follow-up CLs. Add dummy
assets for now until we have proper Chromium assets. google_chrome asests are
downloaded by gclient runhooks. The downloaded files are ignored in .gitignore.

This restructures the asset folders and, thus, makes the presubmit
checks fail. So, I have to bypass the CQ to land this change.

Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:closure_compilation;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_vr;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I006e501443e351980dd91ca8b79bbf95a2d7b392
Reviewed-on: https://chromium-review.googlesource.com/917332
Reviewed-by: Christopher Grant <cjgrant@chromium.org>
Reviewed-by: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#536852}
  • Loading branch information
Tibor Goldschwendt committed Feb 14, 2018
1 parent 0d5b36f commit fd6806b
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 29 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ vs-chromium-project.txt
/chrome/browser/resources/media_router_internal/
/chrome/browser/resources/settings_internal/
/chrome/browser/resources/software_rendering_list
/chrome/browser/resources/vr/assets/*.png
# Asset files downloaded by gclient runhooks.
/chrome/browser/resources/vr/assets/google_chrome/*.png
/chrome/browser/spellchecker/internal
/chrome/browser_tests_run.xml
/chrome/chrome_run.xml
Expand Down
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ hooks = [
'--bucket', 'chrome-vr-assets',
'--recursive',
'--directory',
'src/chrome/browser/resources/vr/assets',
'src/chrome/browser/resources/vr/assets/google_chrome',
],
},
{
Expand Down
30 changes: 26 additions & 4 deletions chrome/browser/resources/vr/assets/PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ def IsNewer(old_version, new_version):
old_version.minor < new_version.minor)))


def CheckVersion(input_api, output_api):
def CheckVersionAndAssetParity(input_api, output_api):
"""Checks that
- the version was upraded if assets files were changed,
- the version was not downgraded.
- the version was not downgraded,
- both the google_chrome and the chromium assets have the same files.
"""
sys.path.append(input_api.PresubmitLocalPath())
import parse_version
Expand All @@ -24,9 +25,21 @@ def CheckVersion(input_api, output_api):
new_version = None
changed_assets = False
changed_version = False
changed_asset_files = {'google_chrome': [], 'chromium': []}
for file in input_api.AffectedFiles():
basename = input_api.os_path.basename(file.LocalPath())
extension = input_api.os_path.splitext(basename)[1][1:].strip().lower()
basename_without_extension = input_api.os_path.splitext(basename)[
0].strip().lower()
if extension == 'sha1':
basename_without_extension = input_api.os_path.splitext(
basename_without_extension)[0]
dirname = input_api.os_path.basename(
input_api.os_path.dirname(file.LocalPath()))
action = file.Action()
if (dirname in changed_asset_files and extension in {'sha1', 'png'} and
action in {'A', 'D'}):
changed_asset_files[dirname].append((action, basename_without_extension))
if (extension == 'sha1' or basename == 'vr_assets_component_files.json'):
changed_assets = True
if (basename == 'VERSION'):
Expand All @@ -38,6 +51,15 @@ def CheckVersion(input_api, output_api):
input_api.os_path.dirname(input_api.AffectedFiles()[0].LocalPath()),
'VERSION')

if changed_asset_files['google_chrome'] != changed_asset_files['chromium']:
return [
output_api.PresubmitError(
'Must have same asset files for %s in \'%s\'.' %
(changed_asset_files.keys(),
input_api.os_path.dirname(
input_api.AffectedFiles()[0].LocalPath())))
]

if changed_version and (not old_version or not new_version):
return [
output_api.PresubmitError(
Expand All @@ -61,8 +83,8 @@ def CheckVersion(input_api, output_api):


def CheckChangeOnUpload(input_api, output_api):
return CheckVersion(input_api, output_api)
return CheckVersionAndAssetParity(input_api, output_api)


def CheckChangeOnCommit(input_api, output_api):
return CheckVersion(input_api, output_api)
return CheckVersionAndAssetParity(input_api, output_api)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions chrome/browser/resources/vr/assets/push_assets_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def main():
assets_dir = os.path.dirname(os.path.abspath(__file__))

files = []
with open(
os.path.join(assets_dir, 'vr_assets_component_files.json')) as json_file:
with open(os.path.join(assets_dir,
'vr_assets_component_files.json')) as json_file:
files = json.load(json_file)

version = None
Expand All @@ -61,16 +61,20 @@ def main():
zip_path = os.path.join(zip_dir, 'vr-assets.zip')

os.makedirs(zip_dir)
zip_files = []
with zipfile.ZipFile(zip_path, 'w') as zip:
for file in files:
file_path = os.path.join(assets_dir, file)
zip.write(file_path, os.path.basename(file_path), zipfile.ZIP_DEFLATED)
for info in zip.infolist():
zip_files.append(info.filename)

# Upload component.
command = ['gsutil', 'cp', '-nR', '.', DEST_BUCKET]
PrintInfo('Going to run the following command', [' '.join(command)])
PrintInfo('In directory', [temp_dir])
PrintInfo('Which pushes the following file', [zip_path])
PrintInfo('Which contains the files', zip_files)

if raw_input('\nAre you sure (y/N) ').lower() != 'y':
print 'aborting'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
"background.png",
"fullscreen_gradient.png",
"incognito_gradient.png",
"normal_gradient.png"
"google_chrome/background.png",
"google_chrome/fullscreen_gradient.png",
"google_chrome/incognito_gradient.png",
"google_chrome/normal_gradient.png"
]
2 changes: 1 addition & 1 deletion chrome/browser/vr/testapp/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ process_version("assets_component_version_header") {

grit("vr_testapp_resources") {
source = "vr_testapp_resources.grd"
defines = [ "background_image_available=$is_chrome_branded" ]
defines = [ "is_chrome_branded=$is_chrome_branded" ]
outputs = [
"grit/vr_testapp_resources.h",
"vr_testapp_resources.pak",
Expand Down
10 changes: 0 additions & 10 deletions chrome/browser/vr/testapp/vr_test_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ void RotateToward(const gfx::Vector3dF& fwd, gfx::Transform* transform) {
transform->PreconcatTransform(gfx::Transform(quat));
}

#if defined(GOOGLE_CHROME_BUILD)
bool LoadPng(int resource_id, std::unique_ptr<SkBitmap>* out_image) {
base::StringPiece data =
ui::ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id);
Expand All @@ -73,7 +72,6 @@ bool LoadPng(int resource_id, std::unique_ptr<SkBitmap>* out_image) {
reinterpret_cast<const unsigned char*>(data.data()), data.size(),
out_image->get());
}
#endif

} // namespace

Expand All @@ -92,9 +90,7 @@ VrTestContext::VrTestContext() : view_scale_factor_(kDefaultViewScaleFactor) {
keyboard_delegate_ = std::make_unique<TestKeyboardDelegate>();

UiInitialState ui_initial_state;
#if defined(GOOGLE_CHROME_BUILD)
ui_initial_state.assets_available = true;
#endif
ui_ = std::make_unique<Ui>(this, nullptr, keyboard_delegate_.get(),
text_input_delegate_.get(), ui_initial_state);
if (ui_initial_state.assets_available) {
Expand Down Expand Up @@ -595,7 +591,6 @@ void VrTestContext::CycleOrigin() {

void VrTestContext::LoadAssets() {
base::Version assets_component_version(VR_ASSETS_COMPONENT_VERSION);
#if defined(GOOGLE_CHROME_BUILD)
auto assets = std::make_unique<Assets>();
if (!(LoadPng(IDR_VR_BACKGROUND_IMAGE, &assets->background) &&
LoadPng(IDR_VR_NORMAL_GRADIENT_IMAGE, &assets->normal_gradient) &&
Expand All @@ -608,11 +603,6 @@ void VrTestContext::LoadAssets() {
}
ui_->OnAssetsLoaded(AssetsLoadStatus::kSuccess, std::move(assets),
assets_component_version);
#else // defined(GOOGLE_CHROME_BUILD)
LOG(ERROR) << "Cannot load assets. Make testapp Chrome branded.";
ui_->OnAssetsLoaded(AssetsLoadStatus::kNotFound, nullptr,
assets_component_version);
#endif // defined(GOOGLE_CHROME_BUILD)
}

RenderInfo VrTestContext::GetRenderInfo() const {
Expand Down
20 changes: 14 additions & 6 deletions chrome/browser/vr/testapp/vr_testapp_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@
</outputs>
<release seq="1">
<includes>
<if expr="background_image_available">
<include name="IDR_VR_BACKGROUND_IMAGE" file="../../resources/vr/assets/background.png" type="BINDATA" />
<include name="IDR_VR_NORMAL_GRADIENT_IMAGE" file="../../resources/vr/assets/normal_gradient.png" type="BINDATA" />
<include name="IDR_VR_INCOGNITO_GRADIENT_IMAGE" file="../../resources/vr/assets/incognito_gradient.png" type="BINDATA" />
<include name="IDR_VR_FULLSCREEN_GRADIENT_IMAGE" file="../../resources/vr/assets/fullscreen_gradient.png" type="BINDATA" />
</if>
<if expr="is_chrome_branded">
<then>
<include name="IDR_VR_BACKGROUND_IMAGE" file="../../resources/vr/assets/google_chrome/background.png" type="BINDATA" />
<include name="IDR_VR_NORMAL_GRADIENT_IMAGE" file="../../resources/vr/assets/google_chrome/normal_gradient.png" type="BINDATA" />
<include name="IDR_VR_INCOGNITO_GRADIENT_IMAGE" file="../../resources/vr/assets/google_chrome/incognito_gradient.png" type="BINDATA" />
<include name="IDR_VR_FULLSCREEN_GRADIENT_IMAGE" file="../../resources/vr/assets/google_chrome/fullscreen_gradient.png" type="BINDATA" />
</then>
<else>
<include name="IDR_VR_BACKGROUND_IMAGE" file="../../resources/vr/assets/chromium/background.png" type="BINDATA" />
<include name="IDR_VR_NORMAL_GRADIENT_IMAGE" file="../../resources/vr/assets/chromium/normal_gradient.png" type="BINDATA" />
<include name="IDR_VR_INCOGNITO_GRADIENT_IMAGE" file="../../resources/vr/assets/chromium/incognito_gradient.png" type="BINDATA" />
<include name="IDR_VR_FULLSCREEN_GRADIENT_IMAGE" file="../../resources/vr/assets/chromium/fullscreen_gradient.png" type="BINDATA" />
</else>
</if>
</includes>
</release>
</grit>

0 comments on commit fd6806b

Please sign in to comment.