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

Commit dcd51165 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 326

* changes:
  modify wait mechanism so that it checks whether activity has already finished or not first
parents 486d95f7 20b4935f
Loading
Loading
Loading
Loading
+9 −17
Original line number Original line Diff line number Diff line
@@ -16,24 +16,11 @@


package com.android.dumprendertree;
package com.android.dumprendertree;


import android.app.Activity;
import android.app.Instrumentation;
import android.app.Instrumentation;
import android.app.Instrumentation.ActivityMonitor;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Intent;
import android.content.Intent;

import android.util.Log;
import android.view.KeyEvent;
import android.webkit.WebSettings;

import android.os.Bundle;
import android.os.Bundle;
import android.os.Message;
import android.test.ActivityInstrumentationTestCase2;
import android.test.ActivityInstrumentationTestCase2;
import android.test.AndroidTestCase;
import android.util.Log;
import android.test.suitebuilder.annotation.LargeTest;

import com.android.dumprendertree.TestShellActivity;


import java.io.BufferedOutputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedReader;
@@ -141,6 +128,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
    private Vector<String> mTestList;
    private Vector<String> mTestList;
    private boolean mRebaselineResults;
    private boolean mRebaselineResults;
    private String mTestPathPrefix;
    private String mTestPathPrefix;
    private boolean mFinished;
    
    
    public LayoutTestsAutoTest() {
    public LayoutTestsAutoTest() {
      super("com.android.dumprendertree", TestShellActivity.class);
      super("com.android.dumprendertree", TestShellActivity.class);
@@ -290,6 +278,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
        activity.setCallback(new TestShellCallback() {
        activity.setCallback(new TestShellCallback() {
            public void finished() {
            public void finished() {
                synchronized (LayoutTestsAutoTest.this) {
                synchronized (LayoutTestsAutoTest.this) {
                    mFinished = true;
                    LayoutTestsAutoTest.this.notifyAll();
                    LayoutTestsAutoTest.this.notifyAll();
                }
                }
            }         
            }         
@@ -306,6 +295,7 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
            resultFile = getAndroidExpectedResultFile(expectedResultFile);
            resultFile = getAndroidExpectedResultFile(expectedResultFile);
        }
        }
        
        
        mFinished = false;
        Intent intent = new Intent(Intent.ACTION_VIEW);
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setClass(activity, TestShellActivity.class);
        intent.setClass(activity, TestShellActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
@@ -316,10 +306,12 @@ public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase2<TestSh
      
      
        // Wait until done.
        // Wait until done.
        synchronized (this) {
        synchronized (this) {
            while(!mFinished){
                try {
                try {
                    this.wait();
                    this.wait();
                } catch (InterruptedException e) { }
                } catch (InterruptedException e) { }
            }
            }
        }
        
        
        if (!mRebaselineResults) {
        if (!mRebaselineResults) {
            String expectedResultFile = getExpectedResultFile(test);
            String expectedResultFile = getExpectedResultFile(test);
+8 −3
Original line number Original line Diff line number Diff line
@@ -37,6 +37,7 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel


    private final static String LOGTAG = "LoadTest";
    private final static String LOGTAG = "LoadTest";
    private final static String LOAD_TEST_RESULT = "/sdcard/load_test_result.txt";
    private final static String LOAD_TEST_RESULT = "/sdcard/load_test_result.txt";
    private boolean mFinished;


    public LoadTestsAutoTest() {
    public LoadTestsAutoTest() {
        super("com.android.dumprendertree", TestShellActivity.class);
        super("com.android.dumprendertree", TestShellActivity.class);
@@ -124,11 +125,13 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel
        activity.setCallback(new TestShellCallback() {
        activity.setCallback(new TestShellCallback() {
            public void finished() {
            public void finished() {
                synchronized (LoadTestsAutoTest.this) {
                synchronized (LoadTestsAutoTest.this) {
                    mFinished = true;
                    LoadTestsAutoTest.this.notifyAll();
                    LoadTestsAutoTest.this.notifyAll();
                }
                }
            }
            }
        });
        });


        mFinished = false;
        Intent intent = new Intent(Intent.ACTION_VIEW);
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setClass(activity, TestShellActivity.class);
        intent.setClass(activity, TestShellActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
@@ -139,9 +142,11 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel


        // Wait until done.
        // Wait until done.
        synchronized (this) {
        synchronized (this) {
            while(!mFinished) {
                try {
                try {
                    this.wait();
                    this.wait();
                } catch (InterruptedException e) { }
                } catch (InterruptedException e) { }
            }
            }
        }
        }
    }
    }
}