Skip to content

Commit

Permalink
Added --disable-animations option to device startup testing. (#2271)
Browse files Browse the repository at this point in the history
* Added --disable-animations option to device startup testing.

* Added exits after logger exceptions, and added actual check to ensure the animation values were properly set.
  • Loading branch information
LoopedBard3 authored Feb 24, 2022
1 parent c58a6cb commit 843c1f6
Showing 1 changed file with 94 additions and 1 deletion.
95 changes: 94 additions & 1 deletion src/scenarios/shared/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import re
import time

from logging import getLogger
from logging import exception, getLogger
from collections import namedtuple
from argparse import ArgumentParser
from argparse import RawTextHelpFormatter
Expand Down Expand Up @@ -62,6 +62,7 @@ def parseargs(self):
parseonlyparser.add_argument('--package-path', help='Location of test application', dest='packagepath')
parseonlyparser.add_argument('--package-name', help='Classname of application', dest='packagename')
parseonlyparser.add_argument('--startup-iterations', help='Startups to run (1+)', type=int, default=5, dest='startupiterations')
parseonlyparser.add_argument('--disable-animations', help='Disable Android device animations', action='store_true', dest='animationsdisabled')
self.add_common_arguments(parseonlyparser)

# inner loop command
Expand Down Expand Up @@ -144,6 +145,7 @@ def parseargs(self):
self.packagename = args.packagename
self.devicetype = args.devicetype
self.startupiterations = args.startupiterations
self.animationsdisabled = args.animationsdisabled

if args.scenarioname:
self.scenarioname = args.scenarioname
Expand Down Expand Up @@ -339,6 +341,77 @@ def run(self):
]
RunCommand(cmdline, verbose=True).run()

# Get animation values
getLogger().info("Getting animation values")
cmdline = [
adb.stdout.strip(),
'shell', 'settings', 'get', 'global', 'window_animation_scale'
]
window_animation_scale_cmd = RunCommand(cmdline, verbose=True)
window_animation_scale_cmd.run()
cmdline = [
adb.stdout.strip(),
'shell', 'settings', 'get', 'global', 'transition_animation_scale'
]
transition_animation_scale_cmd = RunCommand(cmdline, verbose=True)
transition_animation_scale_cmd.run()
cmdline = [
adb.stdout.strip(),
'shell', 'settings', 'get', 'global', 'animator_duration_scale'
]
animator_duration_scale_cmd = RunCommand(cmdline, verbose=True)
animator_duration_scale_cmd.run()
getLogger().info(f"Retrieved values window {window_animation_scale_cmd.stdout.strip()}, transition {transition_animation_scale_cmd.stdout.strip()}, animator {animator_duration_scale_cmd.stdout.strip()}")

# Make sure animations are set to 1 or disabled
getLogger().info("Setting animation values")
if(self.animationsdisabled):
animationValue = 0
else:
animationValue = 1
cmdline = [
adb.stdout.strip(),
'shell', 'settings', 'put', 'global', 'window_animation_scale', str(animationValue)
]
RunCommand(cmdline, verbose=True).run()
cmdline = [
adb.stdout.strip(),
'shell', 'settings', 'put', 'global', 'transition_animation_scale', str(animationValue)
]
RunCommand(cmdline, verbose=True).run()
cmdline = [
adb.stdout.strip(),
'shell', 'settings', 'put', 'global', 'animator_duration_scale', str(animationValue)
]
RunCommand(cmdline, verbose=True).run()

# Check for success
getLogger().info("Getting animation values to verify it worked")
cmdline = [
adb.stdout.strip(),
'shell', 'settings', 'get', 'global', 'window_animation_scale'
]
windowSetValue = RunCommand(cmdline, verbose=True)
windowSetValue.run()
cmdline = [
adb.stdout.strip(),
'shell', 'settings', 'get', 'global', 'transition_animation_scale'
]
transitionSetValue = RunCommand(cmdline, verbose=True)
transitionSetValue.run()
cmdline = [
adb.stdout.strip(),
'shell', 'settings', 'get', 'global', 'animator_duration_scale'
]
animatorSetValue = RunCommand(cmdline, verbose=True)
animatorSetValue.run()
if(int(windowSetValue.stdout.strip()) != animationValue or int(transitionSetValue.stdout.strip()) != animationValue or int(animatorSetValue.stdout.strip()) != animationValue):
# Setting the values didn't work, error out
getLogger().exception(f"Failed to set animation values to {animationValue}.")
exit(-1)
else:
getLogger().info(f"Animation values successfully set to {animationValue}.")

installCmd = xharnesscommand() + [
self.devicetype,
'install',
Expand Down Expand Up @@ -388,6 +461,7 @@ def run(self):
checkScreenOn.run()
if("mInteractive=false" in checkScreenOn.stdout):
getLogger().exception("Failed to make screen interactive.")
exit(-1)

# Actual testing some run stuff
getLogger().info("Test run to check if permissions are needed")
Expand Down Expand Up @@ -438,6 +512,7 @@ def run(self):

if "com.google.android.permissioncontroller" in testRunStats[3]:
getLogger().exception("Failed to get past permission screen, run locally to see if enough next button presses were used.")
exit(-1)

allResults = []
for i in range(self.startupiterations):
Expand All @@ -459,6 +534,24 @@ def run(self):
]
RunCommand(uninstallAppCmd, verbose=True).run()

# Reset animation values
getLogger().info("Resetting animation values to pretest values")
cmdline = [
adb.stdout.strip(),
'shell', 'settings', 'put', 'global', 'window_animation_scale', window_animation_scale_cmd.stdout.strip()
]
RunCommand(cmdline, verbose=True).run()
cmdline = [
adb.stdout.strip(),
'shell', 'settings', 'put', 'global', 'transition_animation_scale', transition_animation_scale_cmd.stdout.strip()
]
RunCommand(cmdline, verbose=True).run()
cmdline = [
adb.stdout.strip(),
'shell', 'settings', 'put', 'global', 'animator_duration_scale', animator_duration_scale_cmd.stdout.strip()
]
RunCommand(cmdline, verbose=True).run()

if screenWasOff:
RunCommand(keyInputCmd + ['26'], verbose=True).run() # Turn the screen back off

Expand Down

0 comments on commit 843c1f6

Please sign in to comment.