Merge "aggregating test results when reporting to instrumentation out."
This commit is contained in:
committed by
Android (Google) Code Review
commit
6f0b2ed37d
@@ -76,7 +76,7 @@ public class DataIdleTest extends InstrumentationTestCase {
|
|||||||
Long.MAX_VALUE, false);
|
Long.MAX_VALUE, false);
|
||||||
reportStats(stats);
|
reportStats(stats);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.w(LOG_TAG, "Failed to fetch network stats for wifi.");
|
Log.w(LOG_TAG, "Failed to fetch network stats.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,16 +85,22 @@ public class DataIdleTest extends InstrumentationTestCase {
|
|||||||
* @param stats {@link NetworkorStats} to print
|
* @param stats {@link NetworkorStats} to print
|
||||||
*/
|
*/
|
||||||
void reportStats(NetworkStats stats) {
|
void reportStats(NetworkStats stats) {
|
||||||
|
Bundle result = new Bundle();
|
||||||
|
long rxBytes = 0;
|
||||||
|
long txBytes = 0;
|
||||||
for (int i = 0; i < stats.size(); ++i) {
|
for (int i = 0; i < stats.size(); ++i) {
|
||||||
|
// Label will be iface_uid_tag_set
|
||||||
Entry statsEntry = stats.getValues(i, null);
|
Entry statsEntry = stats.getValues(i, null);
|
||||||
Bundle result = new Bundle();
|
String labelTemplate = String.format("%s_%d_%d_%d", statsEntry.iface, statsEntry.uid,
|
||||||
result.putInt("uid", statsEntry.uid);
|
statsEntry.tag, statsEntry.set) + "_%s";
|
||||||
result.putInt("tag", statsEntry.tag);
|
result.putLong(String.format(labelTemplate, "rxBytes"), statsEntry.rxBytes);
|
||||||
result.putInt("set", statsEntry.set);
|
result.putLong(String.format(labelTemplate, "txBytes"), statsEntry.txBytes);
|
||||||
result.putString("iface", statsEntry.iface);
|
rxBytes += statsEntry.rxBytes;
|
||||||
result.putLong("rxBytes", statsEntry.rxBytes);
|
txBytes += statsEntry.txBytes;
|
||||||
result.putLong("txBytes", statsEntry.txBytes);
|
|
||||||
getInstrumentation().sendStatus(INSTRUMENTATION_IN_PROGRESS, result);
|
|
||||||
}
|
}
|
||||||
|
result.putLong("Total rxBytes", rxBytes);
|
||||||
|
result.putLong("Total txBytes", txBytes);
|
||||||
|
getInstrumentation().sendStatus(INSTRUMENTATION_IN_PROGRESS, result);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user