Skip to content

Commit

Permalink
Add a new scenario folder named genericandroidstartup and updated the…
Browse files Browse the repository at this point in the history
… android startup scenarios doc to use it.
  • Loading branch information
LoopedBard3 committed Jan 31, 2025
1 parent c72d44a commit a1bc126
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/android-startup-scenarios.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
. ./init.sh # or `.\init.ps1` on Windows. Can specify custom dotnet install with -dotnetdir <dir>, but dotnet install should not impact Android Startup testing itself.
```

2. Navigate to the `helloandroid` scenario directory:
2. Navigate to the `genericandroidstartup` scenario directory:

```sh
cd helloandroid
cd genericandroidstartup
```

3. Copy the APK into the `helloandroid` directory.
3. Copy the APK into the `genericandroidstartup` directory.
4. Run the test:

```sh
Expand Down
7 changes: 7 additions & 0 deletions src/scenarios/genericandroidstartup/post.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'''
post cleanup script
'''

from shared.postcommands import clean_directories

clean_directories()
49 changes: 49 additions & 0 deletions src/scenarios/genericandroidstartup/pre.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'''
pre-command
'''
import sys
import os
from zipfile import ZipFile
from performance.logger import setup_loggers, getLogger
from shutil import copyfile
from shared.precommands import PreCommands
from shared.const import PUBDIR
from argparse import ArgumentParser

setup_loggers(True)

parser = ArgumentParser()
parser.add_argument('--unzip', help='Unzip APK and report extracted tree', action='store_true', default=False)
parser.add_argument(
'--apk-name',
dest='apk',
required=True,
type=str,
help='Name of the APK to setup (with .apk)')
args = parser.parse_args()

if not os.path.exists(PUBDIR):
os.mkdir(PUBDIR)
apkname = args.apk
apknamezip = '%s.zip' % (apkname)
if not os.path.exists(apkname):
getLogger().error('Cannot find %s' % (apkname))
exit(-1)
if args.unzip:
if not os.path.exists(apknamezip):
copyfile(apkname, apknamezip)

with ZipFile(apknamezip) as zip:
zip.extractall(os.path.join('.', PUBDIR))

assets_dir = os.path.join(PUBDIR, 'assets')
assets_zip = os.path.join(assets_dir, 'assets.zip')
with ZipFile(assets_zip) as zip:
zip.extractall(assets_dir)

os.remove(assets_zip)
else:
copyfile(apkname, os.path.join(PUBDIR, apkname))



12 changes: 12 additions & 0 deletions src/scenarios/genericandroidstartup/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'''
C# Console app
'''
from shared.runner import TestTraits, Runner

EXENAME = 'GenericAndroidStartup'

if __name__ == "__main__":
traits = TestTraits(exename=EXENAME,
guiapp='false',
)
Runner(traits).run()

0 comments on commit a1bc126

Please sign in to comment.