Skip to content

Commit 09b13c6

Browse files
authored
Merge pull request #85 from google/useintent
app: run test from an Intent
2 parents 50d15bb + 6f1f700 commit 09b13c6

File tree

11 files changed

+281
-31
lines changed

11 files changed

+281
-31
lines changed

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ android {
66
applicationId "com.sonodroid.synthmark"
77
minSdkVersion 26
88
targetSdkVersion 26
9-
versionCode 6
10-
versionName "1.6"
9+
versionCode 7
10+
versionName "1.7"
1111
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1212
externalNativeBuild {
1313
cmake {

android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package="com.sonodroid.synthmark">
44

55
<uses-permission android:name="android.permission.WAKE_LOCK" />
6+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
67

78
<application
89
android:name=".AppObject"
@@ -11,7 +12,7 @@
1112
android:label="@string/app_name"
1213
android:supportsRtl="true"
1314
android:theme="@style/AppTheme">
14-
<activity android:name=".MainActivity">
15+
<activity android:launchMode="singleTask" android:name=".MainActivity">
1516
<intent-filter>
1617
<action android:name="android.intent.action.MAIN" />
1718

android/app/src/main/java/com/sonodroid/synthmark/AppObject.java

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
public class AppObject extends Application {
3737
public final static String TAG = "SynthMark";
3838

39-
private final static int PROGRESS_REFRESH_RATE_MS = 300;
39+
private final static int PROGRESS_REFRESH_RATE_MS = 200;
4040
private final static int PROGRESS_WARM_UP_WAIT = 300;
4141

4242
private final static int NATIVETEST_STATUS_RUNNING = 2; //from NativeTest.h
@@ -212,6 +212,10 @@ List getParamsForTest(int testId) {
212212
return paramList;
213213
}
214214

215+
List<Param> getParamsForTest() {
216+
return getParamsForTest(getCurrentTestId());
217+
}
218+
215219
@Override
216220
protected void finalize() throws Throwable {
217221
testClose(mNativeTest);
@@ -263,8 +267,11 @@ public static String getDeviceInfo(){
263267
info.append("\n");
264268
}
265269

266-
String boostInfo = readFile(SCHEDTUNE_BOOST_FILE_NAME);
267-
info.append("schedtune.boost: " + boostInfo.trim() + "\n");
270+
String boostInfo = readFile(SCHEDTUNE_BOOST_FILE_NAME).trim();
271+
if (boostInfo.length() == 0) {
272+
boostInfo = "----";
273+
}
274+
info.append("schedtune.boost: " + boostInfo + "\n");
268275

269276
return info.toString();
270277
}
@@ -320,17 +327,20 @@ protected String doInBackground(String... params) {
320327
while (running) {
321328
if (mNativeTest != 0) {
322329
updateProgressBar();
323-
updateOutputReport();
324330

325331
int status = testStatus(mNativeTest);
326332
if (status != NATIVETEST_STATUS_RUNNING) {
327333
running = false;
328334
}
335+
329336
try {
330337
Thread.sleep(PROGRESS_REFRESH_RATE_MS);
331338
} catch (InterruptedException e) {
332339
e.printStackTrace();
333340
}
341+
342+
343+
updateOutputReport();
334344
} else {
335345
break;
336346
}
@@ -358,6 +368,7 @@ private void updateOutputReport() {
358368
protected void onPostExecute(String result) {
359369
log("TestProgressTask.onPostExecute result: " + result);
360370
postNotificationTestShortUpdate(mTestId, result);
371+
postNotificationTestCompleted(mTestId);
361372
}
362373
}
363374

@@ -373,16 +384,15 @@ protected String doInBackground(String... params) {
373384
log("Started running test... ["+mTestId +"]");
374385
testInit(mNativeTest, mTestId);
375386

376-
postNotificationTestUpdate(mTestId, "Test inited");
387+
postNotificationTestUpdate(mTestId, "Test initialized\n");
377388
testRun(mNativeTest);
378389
setRunning(false);
379390

380391
return "done"; // gets passed to onPostExecute()
381392
}
382393

383394
protected void onPostExecute(String result) {
384-
log("TestTack.onPostExecute result: " + result);
385-
postNotificationTestCompleted(mTestId);
395+
log("TestTask.onPostExecute result: " + result);
386396
setRunning(false);
387397
}
388398
}
@@ -425,7 +435,8 @@ public void postNotificationTestStarted(int testId) {
425435
}
426436

427437
public void postNotificationTestUpdate(int testId, String message) {
428-
log("test update");
438+
int end = Math.min(message.length(), 40);
439+
log("Post test update: #" + message.length() + ", " + message.substring(0, end));
429440
Intent intent = new Intent(AppObject.INTENT_NOTIFICATION);
430441
intent.putExtra(INTENT_NOTIFICATION_TYPE, NOTIFICATION_TEST_UPDATE);
431442
intent.putExtra(NOTIFICATION_KEY_TEST_ID, testId);
@@ -434,7 +445,7 @@ public void postNotificationTestUpdate(int testId, String message) {
434445
}
435446

436447
public void postNotificationTestCompleted(int testId) {
437-
log("Test ended");
448+
log("Post test completed");
438449
Intent intent = new Intent(AppObject.INTENT_NOTIFICATION);
439450
intent.putExtra(INTENT_NOTIFICATION_TYPE, NOTIFICATION_TEST_COMPLETED);
440451
intent.putExtra(NOTIFICATION_KEY_TEST_ID, testId);

android/app/src/main/java/com/sonodroid/synthmark/BaseActivity.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ protected void onCreate(Bundle savedInstanceState) {
4040
@Override
4141
protected void onPause() {
4242
super.onPause();
43+
log("onPause() UNregister Broadcast receiver for notification");
4344
LocalBroadcastManager.getInstance(this).unregisterReceiver(mReceiver);
4445
}
4546

4647
@Override
4748
protected void onResume() {
4849
super.onResume();
50+
log("onResume() Register Broadcast receiver for notification");
4951
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver,
5052
new IntentFilter(AppObject.INTENT_NOTIFICATION));
5153
}
@@ -73,26 +75,26 @@ public void setViewEnable(View v, boolean enable) {
7375
}
7476

7577
public void notificationTestStarted(int testId) {
76-
log("notificationTestStarted " + testId);
77-
78+
log("notificationTestStarted(" + testId + ")");
7879
}
7980

8081
public void notificationTestUpdate(int testId, String message) {
81-
log("notificationTestUpdate " + testId + " m: " + message);
82+
log("notificationTestUpdate(" + testId + ",...)");
8283
}
8384

8485
public void notificationTestCompleted(int testId) {
85-
log("notificationTestCompleted " + testId);
86+
log("notificationTestCompleted(" + testId + ")");
8687
}
8788

8889
public void notificationTestShortUpdate(int testId, String message) {
89-
log("notificationTestShortUpdate " + testId + " m: " + message);
90+
// log("notificationTestShortUpdate(" + testId + ", " + message + ")");
9091
}
9192

9293
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
9394
@Override
9495
public void onReceive(Context context, Intent intent) {
9596
int type = intent.getIntExtra(AppObject.INTENT_NOTIFICATION_TYPE, -1);
97+
log("BroadcastReceiver: type = " + type);
9698

9799
switch(type) {
98100
case AppObject.NOTIFICATION_TEST_STARTED: {

0 commit comments

Comments
 (0)