Milosz Wasilewski | ab48dca | 2017-03-30 18:54:46 +0100 | [diff] [blame] | 1 | import time |
| 2 | from common import ApkTestRunner |
| 3 | |
| 4 | |
| 5 | class ApkRunnerImpl(ApkTestRunner): |
| 6 | def __init__(self, config): |
| 7 | self.config = config |
Benjamin Copeland | 15d743e | 2021-02-22 08:35:10 +0000 | [diff] [blame] | 8 | 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 Wasilewski | ab48dca | 2017-03-30 18:54:46 +0100 | [diff] [blame] | 11 | super(ApkRunnerImpl, self).__init__(self.config) |
| 12 | |
| 13 | def execute(self): |
| 14 | # single core test. |
Yongqin Liu | cb654e6 | 2018-08-15 19:47:06 +0800 | [diff] [blame] | 15 | find_start_btn = False |
| 16 | while not find_start_btn: |
Milosz Wasilewski | ab48dca | 2017-03-30 18:54:46 +0100 | [diff] [blame] | 17 | time.sleep(2) |
| 18 | self.dump_always() |
Benjamin Copeland | 15d743e | 2021-02-22 08:35:10 +0000 | [diff] [blame] | 19 | warn_msg = self.vc.findViewWithText( |
Anders Roxell | 6558d37 | 2022-02-02 13:10:51 +0100 | [diff] [blame^] | 20 | "This app was built for an older version of Android and may not work properly. Try checking for updates, or contact the developer." |
Benjamin Copeland | 15d743e | 2021-02-22 08:35:10 +0000 | [diff] [blame] | 21 | ) |
Anders Roxell | 6558d37 | 2022-02-02 13:10:51 +0100 | [diff] [blame^] | 22 | continue_btn = self.vc.findViewWithText("CONTINUE") |
Yongqin Liu | cb654e6 | 2018-08-15 19:47:06 +0800 | [diff] [blame] | 23 | if warn_msg: |
| 24 | self.logger.info("Older version warning popped up") |
Anders Roxell | 6558d37 | 2022-02-02 13:10:51 +0100 | [diff] [blame^] | 25 | warning_ok_btn = self.vc.findViewWithTextOrRaise("OK") |
Yongqin Liu | cb654e6 | 2018-08-15 19:47:06 +0800 | [diff] [blame] | 26 | warning_ok_btn.touch() |
Yongqin Liu | db5f7c0 | 2020-07-24 14:59:53 +0800 | [diff] [blame] | 27 | elif continue_btn: |
| 28 | continue_btn.touch() |
Yongqin Liu | cb654e6 | 2018-08-15 19:47:06 +0800 | [diff] [blame] | 29 | else: |
Benjamin Copeland | 15d743e | 2021-02-22 08:35:10 +0000 | [diff] [blame] | 30 | start_single_button = self.vc.findViewByIdOrRaise( |
| 31 | "com.greenecomputing.linpack:id/btnsingle" |
| 32 | ) |
Yongqin Liu | cb654e6 | 2018-08-15 19:47:06 +0800 | [diff] [blame] | 33 | 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 Wasilewski | ab48dca | 2017-03-30 18:54:46 +0100 | [diff] [blame] | 43 | |
Benjamin Copeland | 15d743e | 2021-02-22 08:35:10 +0000 | [diff] [blame] | 44 | 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 Wasilewski | ab48dca | 2017-03-30 18:54:46 +0100 | [diff] [blame] | 56 | |
| 57 | # Multi core test. |
| 58 | self.dump_always() |
Benjamin Copeland | 15d743e | 2021-02-22 08:35:10 +0000 | [diff] [blame] | 59 | start_multi_button = self.vc.findViewByIdOrRaise( |
| 60 | "com.greenecomputing.linpack:id/btncalculate" |
| 61 | ) |
Milosz Wasilewski | ab48dca | 2017-03-30 18:54:46 +0100 | [diff] [blame] | 62 | start_multi_button.touch() |
| 63 | |
Yongqin Liu | cb654e6 | 2018-08-15 19:47:06 +0800 | [diff] [blame] | 64 | # using start_single_button to check if the test finished |
| 65 | test_finished = False |
| 66 | while not test_finished: |
Milosz Wasilewski | ab48dca | 2017-03-30 18:54:46 +0100 | [diff] [blame] | 67 | time.sleep(2) |
| 68 | self.dump_always() |
Yongqin Liu | cb654e6 | 2018-08-15 19:47:06 +0800 | [diff] [blame] | 69 | if self.vc.findViewById("com.greenecomputing.linpack:id/btnsingle"): |
| 70 | test_finished = True |
Milosz Wasilewski | ab48dca | 2017-03-30 18:54:46 +0100 | [diff] [blame] | 71 | |
Benjamin Copeland | 15d743e | 2021-02-22 08:35:10 +0000 | [diff] [blame] | 72 | 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 Wasilewski | ab48dca | 2017-03-30 18:54:46 +0100 | [diff] [blame] | 84 | |
| 85 | def parseResult(self): |
| 86 | pass |