New screenshots
This commit is contained in:
1 parent
3abc6e2483
commit
c249d6796b
6 files changed
+227
-130
No files matched your search
@@ -8,8 +8,33 @@ repository_directory="${script_directory:h}"
|
||||
derived_data="$repository_directory/.build/mac-marketing-tests"
|
||||
products="$derived_data/Build/Products"
|
||||
backup_directory="$repository_directory/.build/screenshot-backups/$(date +%Y%m%d-%H%M%S)"
|
||||
output_directory="$repository_directory/Marketing/Screenshots/Captures/workspace"
|
||||
output_directory="$repository_directory/Marketing/Screenshots/Captures"
|
||||
marketing_scenes="${TERMIND_MAC_MARKETING_SCENES:-workspace}"
|
||||
marketing_locales="${TERMIND_MAC_MARKETING_LOCALES:-en,zh-Hans,zh-Hant}"
|
||||
local_test_pid=""
|
||||
|
||||
cleanup() {
|
||||
if [[ -n "$local_test_pid" ]]; then
|
||||
kill "$local_test_pid" 2>/dev/null || true
|
||||
wait "$local_test_pid" 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
for scene in ${(s:,:)marketing_scenes}; do
|
||||
case "$scene" in
|
||||
hosts|workspace|agent|command|metrics) ;;
|
||||
*) print -u2 "Unsupported marketing scene: $scene"; exit 64 ;;
|
||||
esac
|
||||
done
|
||||
for language in ${(s:,:)marketing_locales}; do
|
||||
case "$language" in
|
||||
en|zh-Hans|zh-Hant) ;;
|
||||
*) print -u2 "Unsupported marketing locale: $language"; exit 64 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
mkdir -p "$derived_data"
|
||||
xcodebuild \
|
||||
-project "$repository_directory/Termind.xcodeproj" \
|
||||
-scheme TFM \
|
||||
@@ -26,21 +51,34 @@ if [[ -z "$source_xctestrun" ]]; then
|
||||
fi
|
||||
|
||||
capture() {
|
||||
local language="$1"
|
||||
local region="$2"
|
||||
local asset_locale="$3"
|
||||
local apple_locale="$4"
|
||||
local xctestrun="$products/Marketing-TFM-$asset_locale.xctestrun"
|
||||
local test_log="$derived_data/workspace-$asset_locale-capture.log"
|
||||
local destination="$output_directory/mac-$asset_locale.png"
|
||||
local scene="$1"
|
||||
local language="$2"
|
||||
local region asset_locale apple_locale feature prefix
|
||||
local width=2360 height=1480
|
||||
case "$language" in
|
||||
en) region=US; asset_locale=en; apple_locale=en_US ;;
|
||||
zh-Hans) region=CN; asset_locale=zh-hans; apple_locale=zh_CN ;;
|
||||
zh-Hant) region=TW; asset_locale=zh-hant; apple_locale=zh_TW ;;
|
||||
esac
|
||||
prefix=mac
|
||||
case "$scene" in
|
||||
hosts) feature=vault ;;
|
||||
workspace) feature=workspace ;;
|
||||
agent) feature=assistant ;;
|
||||
command) feature=command-generator; width=2044; height=1280 ;;
|
||||
metrics) feature=metrics; prefix=mac-overview ;;
|
||||
esac
|
||||
local xctestrun="$products/Marketing-TFM-$scene-$asset_locale.xctestrun"
|
||||
local test_log="$derived_data/$scene-$asset_locale-capture.log"
|
||||
local destination="$output_directory/$feature/$prefix-$asset_locale.png"
|
||||
local captured="$derived_data/$scene-$asset_locale.png"
|
||||
|
||||
cp "$source_xctestrun" "$xctestrun"
|
||||
/usr/libexec/PlistBuddy \
|
||||
-c 'Add :TFMTests:EnvironmentVariables:TERMIND_MAC_MARKETING_SCREENSHOTS string 1' \
|
||||
-c "Add :TFMTests:EnvironmentVariables:TERMIND_MAC_MARKETING_LOCALE string $language" \
|
||||
-c "Set :TFMTests:TestLanguage $language" \
|
||||
-c "Set :TFMTests:TestRegion $region" \
|
||||
-c "Add :TFMTests:CommandLineArguments:0 string --termind-demo=workspace:$language" \
|
||||
-c "Add :TFMTests:CommandLineArguments:0 string --termind-demo=$scene:$language" \
|
||||
-c 'Add :TFMTests:CommandLineArguments:1 string -AppleLanguages' \
|
||||
-c "Add :TFMTests:CommandLineArguments:2 string ($language)" \
|
||||
-c 'Add :TFMTests:CommandLineArguments:3 string -AppleLocale' \
|
||||
@@ -53,10 +91,10 @@ capture() {
|
||||
-destination 'platform=macOS,arch=arm64' \
|
||||
-only-testing:TFMTests/MacMarketingScreenshotTests \
|
||||
test-without-building > "$test_log" 2>&1 &
|
||||
local test_pid=$!
|
||||
local_test_pid=$!
|
||||
local ready_path=""
|
||||
|
||||
for _ in {1..300}; do
|
||||
for _ in {1..600}; do
|
||||
ready_path="$(
|
||||
rg -o 'TERMIND_MAC_MARKETING_READY .*' "$test_log" \
|
||||
| tail -n 1 \
|
||||
@@ -64,47 +102,53 @@ capture() {
|
||||
|| true
|
||||
)"
|
||||
[[ -n "$ready_path" && -f "$ready_path" ]] && break
|
||||
if ! kill -0 "$test_pid" 2>/dev/null; then
|
||||
if ! kill -0 "$local_test_pid" 2>/dev/null; then
|
||||
tail -n 100 "$test_log" >&2
|
||||
exit 70
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
if [[ -z "$ready_path" || ! -f "$ready_path" ]]; then
|
||||
kill "$test_pid" 2>/dev/null || true
|
||||
tail -n 100 "$test_log" >&2
|
||||
exit 70
|
||||
fi
|
||||
|
||||
local feature captured_language window_id token active key
|
||||
IFS=$'\t' read -r feature captured_language window_id token active key < "$ready_path"
|
||||
if [[ "$feature" != workspace || "$captured_language" != "$language" || "$active" != active || "$key" != key ]]; then
|
||||
local captured_scene captured_language window_id token active key
|
||||
IFS=$'\t' read -r captured_scene captured_language window_id token active key < "$ready_path"
|
||||
if [[ "$captured_scene" != "$scene" || "$captured_language" != "$language" || "$active" != active || "$key" != key ]]; then
|
||||
print -u2 "Capture window was not ready and focused: $(<"$ready_path")"
|
||||
exit 70
|
||||
fi
|
||||
|
||||
mkdir -p "$output_directory" "$backup_directory"
|
||||
if [[ -f "$destination" ]]; then
|
||||
cp "$destination" "$backup_directory/${destination:t}"
|
||||
fi
|
||||
screencapture -l "$window_id" -o "$destination"
|
||||
screencapture -l "$window_id" -o "$captured"
|
||||
touch "${ready_path:h}/ack-$token"
|
||||
wait "$test_pid"
|
||||
|
||||
local dimensions="$(identify -format '%wx%h' "$destination")"
|
||||
if [[ "$dimensions" == 2364x1484 ]]; then
|
||||
sips -c 1480 2360 "$destination" >/dev/null
|
||||
dimensions="$(identify -format '%wx%h' "$destination")"
|
||||
fi
|
||||
if [[ "$dimensions" != 2360x1480 ]]; then
|
||||
print -u2 "Unexpected Workspace dimensions for $asset_locale: $dimensions"
|
||||
if ! wait "$local_test_pid"; then
|
||||
tail -n 100 "$test_log" >&2
|
||||
exit 70
|
||||
fi
|
||||
print "Captured focused Workspace -> ${destination#$repository_directory/}"
|
||||
local_test_pid=""
|
||||
|
||||
local dimensions="$(identify -format '%wx%h' "$captured")"
|
||||
if [[ "$dimensions" == "$((width + 4))x$((height + 4))" ]]; then
|
||||
sips -c "$height" "$width" "$captured" >/dev/null
|
||||
dimensions="$(identify -format '%wx%h' "$captured")"
|
||||
fi
|
||||
if [[ "$dimensions" != "${width}x${height}" ]]; then
|
||||
print -u2 "Unexpected $scene dimensions for $asset_locale: $dimensions"
|
||||
exit 70
|
||||
fi
|
||||
mkdir -p "${destination:h}" "$backup_directory/$feature"
|
||||
if [[ -f "$destination" ]]; then
|
||||
cp "$destination" "$backup_directory/$feature/${destination:t}"
|
||||
fi
|
||||
cp "$captured" "$destination"
|
||||
print "Captured focused $scene -> ${destination#$repository_directory/}"
|
||||
}
|
||||
|
||||
capture en US en en_US
|
||||
capture zh-Hans CN zh-hans zh_CN
|
||||
capture zh-Hant TW zh-hant zh_TW
|
||||
for scene in ${(s:,:)marketing_scenes}; do
|
||||
for language in ${(s:,:)marketing_locales}; do
|
||||
capture "$scene" "$language"
|
||||
done
|
||||
done
|
||||
|
||||
print "Previous raw Workspace captures backed up in ${backup_directory#$repository_directory/}"
|
||||
print "Previous captures backed up in ${backup_directory#$repository_directory/}"
|
||||
@@ -14,13 +14,13 @@ marketing_runtime="${TERMIND_MARKETING_RUNTIME:-com.apple.CoreSimulator.SimRunti
|
||||
|
||||
expected_capture_count() {
|
||||
if [[ -z "$marketing_scenes" ]]; then
|
||||
print 15
|
||||
print 5
|
||||
return
|
||||
fi
|
||||
local -a scenes
|
||||
scenes=("${(@s:,:)marketing_scenes}")
|
||||
local scene_count="${#scenes}"
|
||||
print "$((scene_count * 3))"
|
||||
print "$scene_count"
|
||||
}
|
||||
|
||||
find_device() {
|
||||
@@ -31,33 +31,9 @@ find_device() {
|
||||
| head -n 1
|
||||
}
|
||||
|
||||
set_simulator_orientation() {
|
||||
local name="$1"
|
||||
local orientation="$2"
|
||||
osascript - "$name" "$orientation" <<'APPLESCRIPT'
|
||||
on run arguments
|
||||
set deviceName to item 1 of arguments
|
||||
set targetOrientation to item 2 of arguments
|
||||
tell application "Simulator" to activate
|
||||
tell application "System Events"
|
||||
tell process "Simulator"
|
||||
repeat with candidate in menu items of menu 1 of menu bar item "Window" of menu bar 1
|
||||
if name of candidate starts with deviceName then
|
||||
click candidate
|
||||
exit repeat
|
||||
end if
|
||||
end repeat
|
||||
delay 0.4
|
||||
click menu item targetOrientation of menu 1 of menu item "Orientation" of menu 1 of menu bar item "Device" of menu bar 1
|
||||
end tell
|
||||
end tell
|
||||
end run
|
||||
APPLESCRIPT
|
||||
sleep 1
|
||||
}
|
||||
|
||||
run_capture() {
|
||||
local name="$1"
|
||||
local language="$2"
|
||||
local device_id
|
||||
device_id="$(find_device "$name")"
|
||||
if [[ -z "$device_id" ]]; then
|
||||
@@ -69,14 +45,29 @@ run_capture() {
|
||||
xcrun simctl bootstatus "$device_id" -b
|
||||
if [[ "$name" == iPad* ]]; then
|
||||
xcrun devicectl device orientation set --device "$device_id" landscapeLeft >/dev/null
|
||||
elif pgrep -x Simulator >/dev/null; then
|
||||
set_simulator_orientation "$name" "Portrait"
|
||||
fi
|
||||
xcrun simctl status_bar "$device_id" override \
|
||||
--time '9:41' --batteryState charged --batteryLevel 100 --wifiBars 3 --cellularBars 4
|
||||
local test_log="$derived_data/${device_id}-capture.log"
|
||||
local region apple_locale
|
||||
case "$language" in
|
||||
en) region=US; apple_locale=en_US ;;
|
||||
zh-Hans) region=CN; apple_locale=zh_CN ;;
|
||||
zh-Hant) region=TW; apple_locale=zh_TW ;;
|
||||
esac
|
||||
local localized_xctestrun="$derived_data/Build/Products/Marketing-TFI-$language.xctestrun"
|
||||
cp "$marketing_xctestrun" "$localized_xctestrun"
|
||||
/usr/libexec/PlistBuddy \
|
||||
-c "Add :TFITests:EnvironmentVariables:TERMIND_MARKETING_LOCALE string $language" \
|
||||
-c "Set :TFITests:TestLanguage $language" \
|
||||
-c "Set :TFITests:TestRegion $region" \
|
||||
-c 'Add :TFITests:CommandLineArguments:0 string -AppleLanguages' \
|
||||
-c "Add :TFITests:CommandLineArguments:1 string ($language)" \
|
||||
-c 'Add :TFITests:CommandLineArguments:2 string -AppleLocale' \
|
||||
-c "Add :TFITests:CommandLineArguments:3 string $apple_locale" \
|
||||
"$localized_xctestrun"
|
||||
local test_log="$derived_data/${device_id}-$language-capture.log"
|
||||
xcodebuild \
|
||||
-xctestrun "$marketing_xctestrun" \
|
||||
-xctestrun "$localized_xctestrun" \
|
||||
-destination "id=$device_id" \
|
||||
-only-testing:TFITests/MobileMarketingScreenshotTests \
|
||||
test-without-building > "$test_log" 2>&1 &
|
||||
@@ -129,7 +120,7 @@ run_capture() {
|
||||
local expected
|
||||
expected="$(expected_capture_count)"
|
||||
if [[ "$captures" -ne "$expected" ]]; then
|
||||
print -u2 "Expected $expected captures for $name, received $captures. See $test_log"
|
||||
print -u2 "Expected $expected captures for $name ($language), received $captures. See $test_log"
|
||||
exit 70
|
||||
fi
|
||||
}
|
||||
@@ -168,10 +159,14 @@ if [[ -n "$marketing_scenes" ]]; then
|
||||
fi
|
||||
|
||||
if [[ ",$marketing_devices," == *,iphone,* ]]; then
|
||||
run_capture "iPhone 17 Pro Max"
|
||||
for language in en zh-Hans zh-Hant; do
|
||||
run_capture "iPhone 17 Pro Max" "$language"
|
||||
done
|
||||
fi
|
||||
if [[ ",$marketing_devices," == *,ipad,* ]]; then
|
||||
run_capture "iPad Pro 13-inch (M5)"
|
||||
for language in en zh-Hans zh-Hant; do
|
||||
run_capture "iPad Pro 13-inch (M5)" "$language"
|
||||
done
|
||||
fi
|
||||
|
||||
print "Marketing screenshots written to $output_directory"
|
||||
Reference in new issue
Block a user