Files
yoga/gentest/gentest.rb
Nico Burns 0d28b283e2 Support "align-content: space-evenly" (#1422)
Summary:
X-link: https://github.com/facebook/react-native/pull/41019

### Changes made
- Regenerated tests (as some aspect ratio tests seem to be out of date compared to the fixtures)
- Added SpaceEvenly variant to the "Align" enums (via enums.py)
- Implemented `align-content: space-evenly` alignment in CalculateLayout.cpp
- Added generated tests `align-content: space-evenly`
- Updated NumericBitfield test to account for the fact that the Align enum now requires more bits (this bit could do with being reviewed as I am not 100% certain that it's valid to just update the test like this).

### Changes not made
- Any attempt to improve the spec-compliance of content alignment in general (e.g. I think https://github.com/facebook/yoga/pull/1013 probably still needs to happen)

Pull Request resolved: https://github.com/facebook/yoga/pull/1422

Reviewed By: yungsters

Differential Revision: D50305438

Pulled By: NickGerleman

fbshipit-source-id: ef9f6f14220a0db066bc30db8dd690a4a82a0b00
2023-10-17 20:59:51 -07:00

82 lines
2.4 KiB
Ruby

#!/usr/bin/env ruby
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
require 'watir'
require 'webdrivers'
require 'fileutils'
require 'optparse'
browser = Watir::Browser.new(:chrome, options: {
"goog:loggingPrefs" => {
"browser" => "ALL",
"performance" => "ALL"
},
args: ['--force-device-scale-factor=1', '--window-position=0,0', '--hide-scrollbars']
})
Dir.chdir(File.dirname($0))
options = OpenStruct.new
OptionParser.new do |opts|
opts.on("-s", "--suspend", "Pauses the script after each fixture to allow for debugging on Chrome. Press enter to go to the next fixure.") do
options.suspend = true
end
opts.on("-f", "--fixture [FIXTURE]", String, "Only runs the script on the specific fixture.") do |f|
fixture = "fixtures/" + f + ".html"
if !File.file?(fixture)
puts fixture + " does not exist."
else
options.fixture = fixture
end
end
end.parse!
files = options.fixture ? options.fixture : "fixtures/*.html"
Dir[files].each do |file|
fixture = File.read(file)
name = File.basename(file, '.*')
puts "Generate #{name}"
ltr_fixture = fixture.gsub('start', 'left')
.gsub('end', 'right')
.gsub('flex-left', 'flex-start')
.gsub('flex-right', 'flex-end')
rtl_fixture = fixture.gsub('start', 'right')
.gsub('end', 'left')
.gsub('flex-right', 'flex-start')
.gsub('flex-left', 'flex-end')
template = File.open('test-template.html').read
f = File.open('test.html', 'w')
f.write sprintf(template, name, ltr_fixture, rtl_fixture, fixture)
f.close
FileUtils.copy('test.html', "#{name}.html") if $DEBUG
browser.goto('file://' + Dir.pwd + '/test.html')
logs = browser.driver.logs.get(:browser)
f = File.open("../tests/generated/#{name}.cpp", 'w')
f.write eval(logs[0].message.sub(/^[^"]*/, ''))
f.close
f = File.open("../java/tests/com/facebook/yoga/#{name}.java", 'w')
f.write eval(logs[1].message.sub(/^[^"]*/, '')).sub('YogaTest', name)
f.close
print logs[3]
f = File.open("../javascript/tests/generated/#{name}.test.ts", 'w')
f.write eval(logs[2].message.sub(/^[^"]*/, '')).sub('YogaTest', name)
f.close
if options.suspend
gets
end
end
File.delete('test.html')
browser.close