Target Directed Event Sequence Generation for Android Applications

Jiwei Yan, Tianyong Wu, Jun Yan, Jian ZhangarXiv 2016

Introduction

Testing Android applications remains a significant challenge due to their event-driven nature and highly dynamic user interfaces. Automated testing tools generally fall into two categories: random "monkey" testers and model-based explorers. While random testers are easy to deploy, they often fail to reach deep code paths. Conversely, existing model-based tools frequently suffer from "state collapse"—where distinct functional states are merged—or "state explosion"—where the state space becomes unmanageably large. These issues often stem from ignoring the activity back stack and the internal status of UI widgets.

The LATTE Modeling Approach

To address these limitations, we propose LATTE (Labelled Activity Transition graph with sTack and Events), a dynamic modeling approach. Unlike static analysis, LATTE constructs a model of the application during runtime, capturing the nuances of real-world usage.

Back Stack and Widget Status

LATTE treats the back stack—the history of visited activities—as a primary component of the state. This is crucial because the behavior of the system "back" button depends entirely on this history. Furthermore, LATTE tracks the status of widgets (e.g., whether a checkbox is checked or a text field is focused). A simple toggle can fundamentally change the application's logic, a detail often missed by simpler models.

State Similarity and Merging

To prevent state explosion, we implement a state similarity metric. If two UI states are determined to be "close enough" based on a configurable threshold ($\omega$), they are merged. Through experimentation, we found that a similarity threshold ($S_T$) of 0.8 provides the best balance between model accuracy and construction cost.

Implementation: AppTag

We developed AppTag, a tool that implements the LATTE model. AppTag uses bytecode instrumentation (via smali) to insert probes that link UI transitions to specific code labels. Users can define "targets"—such as specific methods or sensitive API calls—and AppTag uses a modified depth-first search (DFS) on the LATTE model to find the shortest path of events to reach those targets.

Experimental Evaluation

We evaluated AppTag on 20 Android applications, including 10 open-source and 10 commercial apps.

Code Coverage

AppTag achieved approximately 20% higher code coverage on average compared to state-of-the-art tools like Monkey and Dynodroid. In some instances, such as the Terminal app, it achieved 100% class coverage.

Efficiency in Target Reaching

The most significant advantage of AppTag is its efficiency in reaching specific targets. In a case study using the TomDroid note-taking app, we set a target to trigger a "delete/undelete" sequence. This sequence requires navigating through multiple menus and toggling a specific "Show Deleted Notes" setting.

TomDroid navigation: Accessing the note options to delete (b) and navigating to the main settings menu (c).

While a random monkey tester required 50,000 events to hit this target by chance, AppTag reached it in just 12 events once the model was built.

TomDroid target sequence: Toggling 'Show Deleted Notes' in settings (d), selecting 'Undelete Note' from the restored options (e), and verifying the note's return to the list (f).

Conclusion

By incorporating back stack awareness and widget status into a dynamic model, LATTE provides a more accurate representation of Android application behavior. AppTag leverages this model to provide targeted, efficient testing that significantly outperforms random exploration in both coverage and speed. Future work will explore cross-app transitions and the use of temporal logic to define more complex, ordered testing targets.

Summary updated

BibTeX
@misc{yan2016target,
  author = {Jiwei Yan and Tianyong Wu and Jun Yan and Jian Zhang},
  title = {{Target Directed Event Sequence Generation for Android Applications}},
  year = {2016},
  eprint = {1607.03258},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1607.03258},
}
Figure