Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e64bb7a authored by Maksymilian Osowski's avatar Maksymilian Osowski
Browse files

Added more info to the Summarizer.

Bug: 28895725
Change-Id: If02dbdf90e8b8717370b5586cc72be235c93db79
parent 0186c93a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ public class ManagerService extends Service {
                    break;

                case MSG_ALL_TESTS_FINISHED:
                    mSummarizer.setTestsRelativePath(mAllTestsRelativePath);
                    mSummarizer.summarize();
                    Intent intent = new Intent(ManagerService.this, TestsListActivity.class);
                    intent.setAction(Intent.ACTION_SHUTDOWN);
@@ -121,6 +122,8 @@ public class ManagerService extends Service {
    private String mCurrentlyRunningTest;
    private int mCurrentlyRunningTestIndex;

    private String mAllTestsRelativePath;

    @Override
    public void onCreate() {
        super.onCreate();
@@ -131,6 +134,8 @@ public class ManagerService extends Service {

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        mAllTestsRelativePath = intent.getStringExtra("path");
        assert mAllTestsRelativePath != null;
        return START_STICKY;
    }

+45 −13
Original line number Diff line number Diff line
@@ -16,12 +16,20 @@

package com.android.dumprendertree2;

import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.util.DisplayMetrics;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * A class that collects information about tests that ran and can create HTML
@@ -177,7 +185,9 @@ public class Summarizer {
    private FileFilter mFileFilter;
    private String mResultsRootDirPath;

    private String mTitleString;
    private String mTestsRelativePath;

    private Date mDate;

    public Summarizer(FileFilter fileFilter, String resultsRootDirPath) {
        mFileFilter = fileFilter;
@@ -200,6 +210,10 @@ public class Summarizer {
        }
    }

    public void setTestsRelativePath(String testsRelativePath) {
        mTestsRelativePath = testsRelativePath;
    }

    public void summarize() {
        createHtmlDetails();
        createTxtSummary();
@@ -210,13 +224,19 @@ public class Summarizer {
        mFailedNotIgnoredTests.clear();
        mIgnoredTests.clear();
        mPassedNotIgnoredTests.clear();
        mTitleString = null;
        mDate = new Date();
    }

    private void createTxtSummary() {
        StringBuilder txt = new StringBuilder();

        txt.append(getTitleString() + "\n");
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        txt.append(mTestsRelativePath + "\n");
        txt.append("Date: " + dateFormat.format(mDate) + "\n");
        txt.append("Build fingerprint: " + Build.FINGERPRINT + "\n");
        txt.append("WebKit version: " + getWebKitVersionFromUserAgentString() + "\n");

        txt.append("TOTAL:   " + getTotalTestCount() + "\n");
        if (mCrashedTestsCount > 0) {
            txt.append("CRASHED (total among all tests): " + mCrashedTestsCount + "\n");
            txt.append("-------------");
@@ -251,22 +271,34 @@ public class Summarizer {
                html.toString().getBytes(), false);
    }

    private String getTitleString() {
        if (mTitleString == null) {
            int total = mFailedNotIgnoredTests.size() +
    private int getTotalTestCount() {
        return mFailedNotIgnoredTests.size() +
                mPassedNotIgnoredTests.size() +
                mIgnoredTests.size();
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
            mTitleString = " - total of " + total + " tests - " + dateFormat.format(new Date());
    }

        return mTitleString;
    private String getWebKitVersionFromUserAgentString() {
        Resources resources = new Resources(new AssetManager(), new DisplayMetrics(),
                new Configuration());
        String userAgent =
                resources.getString(com.android.internal.R.string.web_user_agent);

        Matcher matcher = Pattern.compile("AppleWebKit/([0-9]+?\\.[0-9])").matcher(userAgent);
        if (matcher.find()) {
            return matcher.group(1);
        }
        return "unknown";
    }

    private void createTopSummaryTable(StringBuilder html) {
        html.append("<h1>" + getTitleString() + "</h1>");
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        html.append("<h1>" + mTestsRelativePath + "</h1>");
        html.append("<h3>" + "Date: " + dateFormat.format(new Date()) + "</h3>");
        html.append("<h3>" + "Build fingerprint: " + Build.FINGERPRINT + "</h3>");
        html.append("<h3>" + "WebKit version: " + getWebKitVersionFromUserAgentString() + "</h3>");

        html.append("<table class=\"summary\">");
        createSummaryTableRow(html, "TOTAL", getTotalTestCount());
        createSummaryTableRow(html, "CRASHED", mCrashedTestsCount);
        createSummaryTableRow(html, "FAILED", mFailedNotIgnoredTests.size());
        createSummaryTableRow(html, "IGNORED", mIgnoredTests.size());
+1 −0
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ public class TestsListActivity extends Activity {
        Message doneMsg = Message.obtain(mHandler, MSG_TEST_LIST_PRELOADER_DONE);

        Intent serviceIntent = new Intent(this, ManagerService.class);
        serviceIntent.putExtra("path", path);
        startService(serviceIntent);

        new TestsListPreloaderThread(path, doneMsg).start();