Book Image

Learning Android Application Testing

Book Image

Learning Android Application Testing

Overview of this book

Table of Contents (16 chapters)
Learning Android Application Testing
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Ye Olde Logge method


Sometimes, this is too simplistic for real-life scenarios but I'm not going to say that it could not help in some cases, mainly because its implementation takes minutes and you only need the logcat text output to analyze the case. This comes in handy during situations where you want to automate procedures or apply continuous integration, as described in previous chapters.

This method consists of timing a method (or a part of it), surrounding it by two time measures, and logging the difference at the end:

private static final boolean BENCHMARK_TEMPERATURE_CONVERSION = true;

@Override
public void onTextChanged(CharSequence input, int start, int before, int count) {
if (!destinationEditNumber.hasWindowFocus() 
  || destinationEditNumber.hasFocus() || input == null) {
     return;
}

String str = input.toString();
if ("".equals(str)) {
    destinationEditNumber.setText("");
    return;
}

long t0;
if (BENCHMARK_TEMPERATURE_CONVERSION) {
    t0 = System.currentTimeMillis(...