b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

robotium和appium区别_robotium自动化测试_robotium(3)

电脑杂谈  发布时间:2017-01-17 19:01:01  来源:网络整理
/*      */   public void start()
/*      */   {
/*  122 */     if (this.mRunner != null) {
/*  123 */       throw new RuntimeException("Instrumentation already started");
/*      */     }
/*  125 */     this.mRunner = new InstrumentationThread("Instr: " + getClass().getName());
/*  126 */     this.mRunner.start();
/*      */   }
在第125行我们很明显知道新的线程名就叫做"Instr:android.test.InstrumentationTestRunner",因为这个方法是从子类android.test.InstrumentationTestRunner中传进来的,所以getClass().getName()方法获得的就是子类的名字。

我们继续看这个线程是如何建立起来的,继续进入InstrumentationThread这个Instrumentation的内部类:

/*      */   private final class InstrumentationThread
/*      */     extends Thread {
/* 1689 */     public InstrumentationThread(String name) { super(); }
/*      */     
/*      */     public void run() {
/*      */       try {
/* 1693 */         Process.setThreadPriority(-8);
/*      */       } catch (RuntimeException e) {
/* 1695 */         Log.w("Instrumentation", "Exception setting priority of instrumentation thread " + Process.myTid(), e);
/*      */       }
/*      */       
/* 1698 */       if (Instrumentation.this.mAutomaticPerformanceSnapshots) {
/* 1699 */         Instrumentation.this.startPerformanceSnapshot();
/*      */       }
/* 1701 */       Instrumentation.this.onStart();
/*      */     }
/*      */   }
从最前面的定义可看到该类是继承与Thread对象的,所以后面提供个重写的run方法来代表该线程的运行入口完成一个Thread线程的完整实现。1701行,Instrumentation.this得就是子类InstrumentationTestRunner的实例,那么它的onStart方法又做了什么事情呢?


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/ruanjian/article-26961-3.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    • 鲁宛
      鲁宛

      但对有损我国主权的行为

    热点图片
    拼命载入中...