blob: 43299f647260ef7e3bb79394e47a8918ef5e607c [file] [log] [blame]
Milosz Wasilewskiab48dca2017-03-30 18:54:46 +01001import time
2from common import ApkTestRunner
3
4
5class ApkRunnerImpl(ApkTestRunner):
6 def __init__(self, config):
7 self.config = config
Benjamin Copeland15d743e2021-02-22 08:35:10 +00008 self.config["apk_file_name"] = "com.greenecomputing.linpack-1.apk"
9 self.config["apk_package"] = "com.greenecomputing.linpack"
10 self.config["activity"] = "com.greenecomputing.linpack/.Linpack"
Milosz Wasilewskiab48dca2017-03-30 18:54:46 +010011 super(ApkRunnerImpl, self).__init__(self.config)
12
13 def execute(self):
14 # single core test.
Yongqin Liucb654e62018-08-15 19:47:06 +080015 find_start_btn = False
16 while not find_start_btn:
Milosz Wasilewskiab48dca2017-03-30 18:54:46 +010017 time.sleep(2)
18 self.dump_always()
Benjamin Copeland15d743e2021-02-22 08:35:10 +000019 warn_msg = self.vc.findViewWithText(
Anders Roxell6558d372022-02-02 13:10:51 +010020 "This app was built for an older version of Android and may not work properly. Try checking for updates, or contact the developer."
Benjamin Copeland15d743e2021-02-22 08:35:10 +000021 )
Anders Roxell6558d372022-02-02 13:10:51 +010022 continue_btn = self.vc.findViewWithText("CONTINUE")
Yongqin Liucb654e62018-08-15 19:47:06 +080023 if warn_msg:
24 self.logger.info("Older version warning popped up")
Anders Roxell6558d372022-02-02 13:10:51 +010025 warning_ok_btn = self.vc.findViewWithTextOrRaise("OK")
Yongqin Liucb654e62018-08-15 19:47:06 +080026 warning_ok_btn.touch()
Yongqin Liudb5f7c02020-07-24 14:59:53 +080027 elif continue_btn:
28 continue_btn.touch()
Yongqin Liucb654e62018-08-15 19:47:06 +080029 else:
Benjamin Copeland15d743e2021-02-22 08:35:10 +000030 start_single_button = self.vc.findViewByIdOrRaise(
31 "com.greenecomputing.linpack:id/btnsingle"
32 )
Yongqin Liucb654e62018-08-15 19:47:06 +080033 start_single_button.touch()
34 find_start_btn = True
35
36 # using start_single_button to check if the test finished
37 test_finished = False
38 while not test_finished:
39 time.sleep(2)
40 self.dump_always()
41 if self.vc.findViewById("com.greenecomputing.linpack:id/btnsingle"):
42 test_finished = True
Milosz Wasilewskiab48dca2017-03-30 18:54:46 +010043
Benjamin Copeland15d743e2021-02-22 08:35:10 +000044 mflops_single_score = self.vc.findViewByIdOrRaise(
45 "com.greenecomputing.linpack:id/txtmflops_result"
46 )
47 time_single_score = self.vc.findViewByIdOrRaise(
48 "com.greenecomputing.linpack:id/txttime_result"
49 )
50 self.report_result(
51 "Linpack-MFLOPSSingleScore", "pass", mflops_single_score.getText(), "MFLOPS"
52 )
53 self.report_result(
54 "Linpack-TimeSingleScore", "pass", time_single_score.getText(), "seconds"
55 )
Milosz Wasilewskiab48dca2017-03-30 18:54:46 +010056
57 # Multi core test.
58 self.dump_always()
Benjamin Copeland15d743e2021-02-22 08:35:10 +000059 start_multi_button = self.vc.findViewByIdOrRaise(
60 "com.greenecomputing.linpack:id/btncalculate"
61 )
Milosz Wasilewskiab48dca2017-03-30 18:54:46 +010062 start_multi_button.touch()
63
Yongqin Liucb654e62018-08-15 19:47:06 +080064 # using start_single_button to check if the test finished
65 test_finished = False
66 while not test_finished:
Milosz Wasilewskiab48dca2017-03-30 18:54:46 +010067 time.sleep(2)
68 self.dump_always()
Yongqin Liucb654e62018-08-15 19:47:06 +080069 if self.vc.findViewById("com.greenecomputing.linpack:id/btnsingle"):
70 test_finished = True
Milosz Wasilewskiab48dca2017-03-30 18:54:46 +010071
Benjamin Copeland15d743e2021-02-22 08:35:10 +000072 mflops_multi_score = self.vc.findViewByIdOrRaise(
73 "com.greenecomputing.linpack:id/txtmflops_result"
74 )
75 time_multi_score = self.vc.findViewByIdOrRaise(
76 "com.greenecomputing.linpack:id/txttime_result"
77 )
78 self.report_result(
79 "Linpack-MFLOPSMultiScore", "pass", mflops_multi_score.getText(), "MFLOPS"
80 )
81 self.report_result(
82 "Linpack-TimeMultiScore", "pass", time_multi_score.getText(), "seconds"
83 )
Milosz Wasilewskiab48dca2017-03-30 18:54:46 +010084
85 def parseResult(self):
86 pass