Sie sind auf Seite 1von 37

Android Testing

Version#1
Dated: 01/07
Bangalore

12/17/2019 1
Android Introduction

• Android is a software stack for mobile devices that includes an operating system,
middleware and key applications. The Android SDK provides the tools and APIs
necessary to begin developing applications on the Android platform using the Java
programming language.
• Android is a mobile operating system initially developed by Android Inc.
• Android was bought by Google in 2005.
• Android is based upon a modified version of the Linux kernel.
• Google and other members of the Open Handset Alliance collaborated to develop
and release Android to the world.
• There are currently over 200,000 apps available for Android.
• Android Market is the online app store run by Google, though apps can be
downloaded from third party sites (except on AT&T, which disallows this).
• Applications
Android will ship with a set of core applications including an email client, SMS
program, calendar, maps, browser, contacts, and others. All applications are written
using the Java programming language.

Presentation Template 12/17/2019 2


Android Features

Features:
• Application framework enabling reuse and replacement of components
• Dalvik virtual machine optimized for mobile devices
• Integrated browser based on the open source WebKit engine
• Optimized graphics powered by a custom 2D graphics library; 3D graphics based
on the OpenGL ES 1.0 specification (hardware acceleration optional)
• SQLite for structured data storage
• Media support for common audio, video, and still image formats (MPEG4, H.264,
MP3, AAC, AMR, JPG, PNG, GIF)
• GSM Telephony (hardware dependent)
• Bluetooth, EDGE, 3G, and WiFi (hardware dependent)
• Camera, GPS, compass, and accelerometer (hardware dependent)
• Rich development environment including a device emulator, tools for debugging,
memory and performance profiling, and a plugin for the Eclipse IDE

Presentation Template 12/17/2019 3


Update History

• 1.0 : Released 23 September 2008


• 1.1 : Released 9 February 2009
• 1.5 (Cupcake) :
Based on Linux Kernel 2.6.27 On 30 April 2009, the official 1.5 (Cupcake) update
for Android was released. There were several new features and UI updates
included in the 1.5 update:
o Ability to record and watch videos through camcorder mode.
o Uploading videos to YouTube and pictures to Picasa directly from the phone
o A new soft-keyboard with text-prediction
o Bluetooth A2DP and AVRCP support
o Ability to automatically connect to a Bluetooth headset within a certain
distance
o New widgets and folders that can populate the Home screens
o Animated screen transitions

Presentation Template 12/17/2019 4


Update History Contd…

• 1.6 (Donut) :
Based on Linux Kernel 2.6.29 On 15 September 2009, the 1.6 (Donut) SDK was
released.
Included in the update were:
o An improved Android Market experience
o An integrated camera, camcorder, and gallery interface
o Gallery now enables users to select multiple photos for deletion
o Updated Voice Search, with faster response and deeper integration with native
applications, including the ability to dial contacts
o Updated search experience to allow searching bookmarks, history, contacts,
and the web from the home screen
o Updated technology support for CDMA/EVDO, 802.1x, VPNs, and a text-to-
speech engine
o Support for WVGA screen resolutions
o Speed improvements in searching and camera applications
o Gesture framework and GestureBuilder development tool
o Google free turn-by-turn navigation

Presentation Template 12/17/2019 5


Update History Contd…
• 2.0 / 2.1 (Eclair)
Based on Linux Kernel 2.6.29On 26 October 2009, the 2.0 (Eclair) SDK was
released.Changes include:
o Optimized hardware speed
o Support for more screen sizes and resolutions
o Revamped UI
o New Browser UI and HTML5 support
o New contact lists
o Better contrast ratio for backgrounds
o Improved Google Maps 3.1.2
o Microsoft Exchange support
o Built in flash support for Camera
o Digital Zoom
o MotionEvent class enhanced to track multi-touch events
o Improved virtual keyboard
o Bluetooth 2.1
o Live Wallpapers
• The 2.0.1 SDK was released on 3 December 2009.
• The 2.1 SDK was released on 12 January 2010.

Presentation Template 12/17/2019 6


Update History Contd…
• 2.2 (Froyo) :
Based on Linux Kernel 2.6.32 On 20 May 2010, the 2.2 (Froyo) SDK was released.
Changes included:
o General Android OS speed, memory, and performance optimizations.
o Additional application speed improvements courtesy of JIT implementation.
o Integration of Chrome's V8 JavaScript engine into the Browser application
o Increased Microsoft Exchange support (security policies, auto-discovery, GAL look-up,
calendar synchronization, remote wipe)
o Improved application launcher with shortcuts to Phone and Browser applications
o USB tethering and Wi-Fi hotspot functionality
o Added an option to disable data access over mobile network
o Updated Market application with batch and automatic update features.
o Quick switching between multiple keyboard languages and their dictionaries
o Voice dialing and contact sharing over Bluetooth
o Support for numeric and alphanumeric passwords
o Support for file upload fields in the Browser application.
o Support for installing applications to the expandable memory
o Adobe Flash 10.1 support.
o Support for extra high DPI screens (320 dpi), such as 4" 720p.

Presentation Template 12/17/2019 7


Update History Contd…
• 2.3 (Gingerbread) : Based on Linux Kernel 2.6.35.7
On 6 December 2010, the 2.3 (Gingerbread) SDK was released.Changes included:
o Updated user interface design
o Support for extra-large screen sizes and resolutions (WXGA and higher)
o Native support for SIP VoIP telephony
o Support for WebM/VP8 video playback, and AAC audio encoding
o New audio effects such as reverb, equalization, headphone virtualization, and bass
boost
o System-wide copy–paste functionalities
o Redesigned multi-touch software keyboard
o Enhanced support for native code development
o Audio, graphical, and input enhancements for game developers
o Concurrent garbage collection for increased performance
o Native support for more sensors (such as gyroscopes and barometers)
o A download manager for long running downloads
o Improved power management and application control via a Task Manager.
o Native support for multiple cameras
o Switched from YAFFS to the ext4 filesystem
• Honeycomb : Better tablet support
• Ice Cream
Presentation Template 12/17/2019 8
Android Tools

• Android Development Tools Plugin : (for the Eclipse IDE) The ADT plugin adds
powerful extensions to the Eclipse integrated environment, making creating and
debugging your Android applications easier and faster. If you use Eclipse, the ADT
plugin gives you an incredible boost in developing Android applications.
• Android Emulator :A QEMU-based device-emulation tool that you can use to
design, debug, and test your applications in an actual Android run-time
environment.
• Android Virtual Devices :(AVDs) Virtual device configurations that you create, to
model device characteristics in the Android Emulator. In each configuration, you
can specify the Android platform to run, the hardware options, and the emulator
skin to use. Each AVD functions as an independent device with it's own storage for
user data, SD card, and so on.
• Hierarchy Viewer :The Hierarchy Viewer tool allows you to debug and optimize
your user interface. It provides a visual representation of your layout's hierarchy of
Views and a magnified inspector of the current display with a pixel grid, so you can
get your layout just right.

Presentation Template 12/17/2019 9


Android Tools Contd…

• layoutopt :This tool lets you quickly analyze your application's layouts for
efficiency.
• Draw 9-patch :The Draw 9-patch tool allows you to easily create a NinePatch
graphic using a WYSIWYG editor. It also previews stretched versions of the image,
and highlights the area in which content is allowed.
• Dalvik Debug Monitor Service :(ddms) Integrated with Dalvik, the Android
platform's custom VM, this tool lets you manage processes on an emulator or
device and assists in debugging. You can use it to kill processes, select a specific
process to debug, generate trace data, view heap and thread information, take
screenshots of the emulator or device, and more.
• Android Debug Bridge :(adb) appThe adb tool lets you install your application's
.apk files on an emulator or device and access the emulator or device from a
command line. You can also use it to link a standard debugger to lication code
running on an Android emulator or device. This is located in <sdk>/platform-tools/.

Presentation Template 12/17/2019 10


Android Tools Contd…

• Android Asset Packaging Tool: (aapt) The aapt tool lets you create .apk files
containing the binaries and resources of Android applications.
• Android Interface Description Language :(aidl) Lets you generate code for an
interprocess interface, such as what a service might use.
• Sqlite3: Included as a convenience, this tool lets you access the SQLite data files
created and used by Android applications.
• Traceview: This tool produces graphical analysis views of trace log data that you
can generate from your Android application.
• Mksdcard: Helps you create a disk image that you can use with the emulator, to
simulate the presence of an external storage card (such as an SD card).
• Dx: The dx tool rewrites .class bytecode into Android bytecode (stored in .dex files.)

Presentation Template 12/17/2019 11


Android Tools Contd…

• UI/Application Exerciser Monkey: The Monkey is a program that runs on your


emulator or device and generates pseudo-random streams of user events such as
clicks, touches, or gestures, as well as a number of system- level events. You can
use the Monkey to stress-test applications that you are developing, in a random yet
repeatable manner.
• monkeyrunner :The monkeyrunner tool provides an API for writing Python
programs that control an Android device or emulator from outside of Android code.
• Android: A script that lets you manage AVDs and generate Ant build files that you
can use to compile your Android applications.
• zipalign: An important .apk optimization tool. This tool ensures that all
uncompressed data starts with a particular alignment relative to the start of the file.
This should always be used to align .apk files after they have been signed.

Presentation Template 12/17/2019 12


UI Guidelines

Four fundamental concepts in the Android system that are helpful for you to understand
are:
o Applications
o Activities
o Activity Stack
o Tasks
Examples of applications and the activities they might contain:
o Email - activities to view folders, view list of messages, view a message, compose
a message, and set up an account.
o Calendar - activities to view day, view week, view month, view agenda, edit an
event, edit preferences, and view an alert
o Camera - activities for running the camera, viewing the list of pictures, viewing a
picture, cropping a picture, running the camcorder, viewing the list of movies, and
viewing a movie
o Game - one activity to play the game, typically another for setup
o Maps - one activity to view a location on a map, a second for lists (such as turn list
or friend list), and a third for details (friend location, status, photo).

Presentation Template 12/17/2019 13


UI Guidelines Contd…

Activity Stack:
As the user moves from activity to activity, across applications, the Android system
keeps a linear navigation history of activities the user has visited. This is the activity
stack, also known as the back stack.
Task:
A task is the sequence of activities the user follows to accomplish an objective,
regardless of which applications the activities belong to
o Send a text message with an attachment
o View a YouTube video and share it by email with someone else

Presentation Template 12/17/2019 14


UI Guidelines Contd…

Navigating Away from an Activity with BACK and HOME keys:


1.Home -> Email App-> List of Messages -> Scroll -> Back Key -> Home(Current
activity is destroyed and goes back to previous activity)
Again Email App -> start of the list of Messages(Not the scrolled condition)
2. Home -> Email App-> List of Messages -> Scroll -> Home Key ->(Crrent activity is
stopped and goes to background)
Again Email App -> scrolled condn of list of messages
3. Home > Contacts -> chooses a contact, viewing the details of a contact. Start again
by choosing Home > Contacts, are presented with the initial list of contacts rather
than the contact last viewing. Contacts is designed this way because this initial
screen is the main entry point for the application with four tabs for accessing the full
range of features.
4. When the user starts playing music in the Music application and then presses BACK,
the application overrides the normal back behavior, preventing the player activity
from being destroyed, and continues playing music, even though its activity is no
longer visible
Presentation Template 12/17/2019 15
UI Guidelines Contd…

Re-using an Activity:
When activity A starts activity B in a different application, activity B is said to be reused.
• Contacts Re-Uses Gallery to Get a Picture - The Contacts activity has a field for a picture
of a contact, but the Gallery is normally where pictures are kept. So Contacts can re-use the
Gallery activity to get a picture. Notice the Gallery returns a picture to the Contacts
application that started it.
• Gallery Re-Uses Messaging for Sharing a Picture - Sharing is another good example of
one application re-using an activity from a different application. User starts Gallery, picks a
picture to view, chooses MENU > Share, and picks "Messaging". This starts the Messaging
activity, creates a new message and attaches the original picture to it. The user then fills in
the "To" field, writes a short message and sends it. User focus remains in the Messaging
program. If the user wants to go back to the Gallery, they must press the BACK key. In
contrast to the previous example, this re-use of the Messaging activity does not return
anything to the Gallery activity that started it.

Presentation Template 12/17/2019 16


UI Guidelines Contd…
Replacing an Activity:
• This is the use case where activity A replaces activity B in a different application. This situation normally
happens because activity A is better at doing the job than activity B. In other words, A and B are
equivalent enough that A can replace B.
• User has downloaded a replacement for the Phone Ringtone activity, called Rings Extended. Go to
Settings, Sound & Display, Phone Ringtone, the system presents a choice between the Android
System's ringtone activity and the new one. This dialog box has an option to remember their choice "Use
by default for this action". When they choose "Rings Extended", that activity loads, replacing the original
Android ringtone activity.
Multitasking:
• when an activity has been launched, the user can go to Home and launch a second activity without
destroying the first activity.
o State 1 - The user launches the View Map activity and searches for a map location. Let's say the
network is slow, so the map is taking an unusually long taking time to draw.
o State 2 - The user wants to do something else while they're waiting, so they press HOME, which
does not interrupt the map's network connection and allows the map to continue loading in the
background.
o State 3 - The map activity is now running in the background, with Home in the foreground. The user
then launches the Calendar activity, which launches into the foreground, taking user focus, where
they view today's calendar
o State 4 - The user presses Home, then Maps to return to the map, which12/17/2019
Presentation Template
by now has fully loaded. 17
UI Guidelines Contd…
Switching Between Tasks :
o Start first task. You want to send a text message and attach a photo. You would
choose: Home > Messaging > New message > MENU > Attach > Pictures. This last
step launches the picture gallery for picking a photo. Notice that picture gallery is an
activity in a separate application.
At this point, before you have picked a picture, you decide to stop and glance at your
calendar, which is a separate task. Because the current activity has no button to go
directly to the Calendar, you need to start from Home.
o Start second task. You choose Home > Calendar to look at a calendar event. Calendar
launches from Home as a new task because the application launcher creates a new
task for each application it launches.
o Switch to first task and complete it. When done looking at the Calendar, you can
return to attaching the picture by starting the root activity again for that task: choose
Home > Messaging, which takes you not to Messaging, but directly to the Picture
gallery, where you left off. You can then pick a photo, which is added to the message,
you send the message and you're done with the first task.
More Information:
http://developer.android.com/guide/practices/ui_guidelines/index.html
Presentation Template 12/17/2019 18
Steps to install .apk on the device

1. On the device go to Settings => Applications and select the check box next to
“Unknown Sources” (Allow installation of non-Market applications).
2. On the device go to Settings => Applications => Development and select the
check box next to “USB Debugging” (Debug mode when USB is connected).
3. Connect the Android Device to your PC.
4. Install the USB driver (either using OEM Sync software or using Android AVD
Manager)
5. Go to Android SDK Tools directory (C:\android-sdk-windows-1.6_r1\tools)
6. Copy the .apk files in to the Android tools directory
7. Open the command prompt & locate the Android tools path
8. Check whether the Android device is recognized by the system or not by entering
the command: adb devices
9. Type the command: adb install <.apk file name>

Presentation Template 12/17/2019 19


Steps to install .apk in emulator from Cmd Prompt

1. Go to Android SDK Tools directory (C:\android-sdk-windows-1.6_r1\tools)


2. Copy the .apk files in to the Android tools directory
3. Open the command prompt & locate the Android tools path
4. Type the command: android create avd –n <avd_name> -t 3
5. Type the command: emulator –avd <avd_name>
6. Check whether the Android emulator is recognized by the system or not by
entering the command: adb devices
7. On the emulator go to Settings => Applications and select the check box next to
“Unknown Sources” (Allow installation of non-Market applications).
8. On the emulator go to Settings => Applications => Development and select the
check box next to “USB Debugging” (Debug mode when USB is connected).
9. Type the command: adb install <.apk file name>

Presentation Template 12/17/2019 20


Steps to run android project in emulator (On Eclipse)

1. Install Eclipse SDK.


2. Run eclipse.exe
3. Creating an android project.
• Select File > New > Project.
• Select Android > Android Project, and click Next.
• Select the contents for the project:

o Enter a Project Name. This will be the name of the folder where your
project is created.
o Under Contents, select Create new project in workspace. Select your
project workspace location.
o Under Target, select an Android target to be used as the project's Build
Target. The Build Target specifies which Android platform you'd like your
application built against.

Presentation Template 12/17/2019 21


Steps to run android project in emulator (On Eclipse
contd..)
• Unless you know that you'll be using new APIs introduced in the latest SDK, you
should select a target with the lowest platform version possible.
• Note: You can change your Build Target for your project at any time: Right-click the
project in the Package Explorer, select Properties select Android and then check
the desired Project Target.
o Under Properties, fill in all necessary fields.
– Enter an Application name. This is the human-readable title for your application — the
name that will appear on the Android device.
– Enter a Package name. This is the package namespace (following the same rules as for
packages in the Java programming language) where all your source code will reside.
– Select Create Activity (optional, of course, but common) and enter a name for your main
Activity class.
– Enter a Min SDK Version. This is an integer that indicates the minimum API Level
required to properly run your application. Entering this here automatically sets the
minSdkVersion attribute in the <uses-sdk> of your Android Manifest file. If you're unsure
of the appropriate API Level to use, copy the API Level listed for the Build Target you
selected in the Target tab.
• Click Finish.

Presentation Template 12/17/2019 22


Steps to run android project in emulator (On Eclipse
contd…)

4. Creating an AVD
5. Running the application on emulator.
6. Creating a Run Configuration (select Run > Run Configurations (or Debug
Configurations)

Presentation Template 12/17/2019 23


Steps to install .apk in emulator (On Eclipse)

1. Create an AVD
2. Create a Run Configuration (select Run > Run Configurations (or
Debug Configurations).
3. Go to Android SDK Tools directory (C:\android-sdk-windows-
1.6_r1\tools)
4. Copy the .apk files in to the Android tools directory
5. Open the command prompt & locate the Android tools path
6. Check whether the Android device is recognized by the system or
not by entering the command: adb devices
7. Type the command: adb install <.apk file name>

Presentation Template 12/17/2019 24


Advantages of using the Eclipse

• If you use Eclipse, the ADT plug-in gives you an incredible boost in developing
Android applications:
• It gives you access to other Android development tools from inside the Eclipse IDE.
For example, ADT lets you access the many capabilities of the DDMS tool: take
screenshots, manage port-forwarding, set breakpoints, and view thread and
process information directly from Eclipse.
• It provides a New Project Wizard, which helps you quickly create and set up all of
the basic files you'll need for a new Android application.
• It automates and simplifies the process of building your Android application.
• It provides an Android code editor that helps you write valid XML for your Android
manifest and resource files.
• It will even export your project into a signed APK, which can be distributed to users.

Presentation Template 12/17/2019 25


Capturing the screenshots using the DDMS (cmd prompt):

1. .apk file has been installed on the device/emulator.


2. Application is running on the device/emulator.
3. Open the command prompt & locate the Android tools path
4. Type the command: ddms.bat
5. You will see the DDMS screen (refer next slide).
6. Select the device/emulator (In the figure “emulator-5554”)
7. Now select Device => Screen Capture
8. Click the ‘Copy’ button and ‘Save’ button.

Presentation Template 12/17/2019 26


Capturing the screenshots using the DDMS (cmd prompt): Contd..

Presentation Template 12/17/2019 27


Capturing the screenshot using the DDMS (Eclipse):

1. .apk file has been installed on the device/emulator.


2. Application is running on the device/emulator.
3. On the Java Eclipse browser click the “DDMS” button (top right corner).
4. You will see the DDMS screen (refer the next slide).
5. Select the device from the Device panel.
6. Click on the screen capture icon on the Device panel.
7. Click the ‘Copy’ button and ‘Save’ button.

Presentation Template 12/17/2019 28


Capturing the screenshot using the DDMS (Eclipse): Contd..

Presentation Template 12/17/2019 29


UI/Application Exerciser Monkey Tool

Monkey Tool:
The Monkey is a command-line tool that you can run on any emulator instance or
on a device. It sends a pseudo-random stream of user events into the system,
which acts as a stress test on the application software we are developing.
The Monkey is a program that runs on your emulator or device and generates
pseudo-random streams of user events such as clicks, touches, or gestures, as
well as a number of system-level events. You can use the Monkey to stress-test
applications that you are developing, in a random yet repeatable manner.
Set up:
• Android sdk should be installed and Set the path for android sdk.
• Eg: Export PATH=/home/partha/Desktop/android-sdk-linux_x86-1.5_r2/android-
sdk-linux_x86-1.5_r2/tools:$PATH

Presentation Template 12/17/2019 30


UI/Application Exerciser Monkey Tool Contd…

Procedure to run monkey tool on Emulator:


• We can start the emulator from the installed location path.
• Once Emulator connected go to the cmd type below command to know the device
is connected or not.
• Type “adb devices”.
• List of connected devices should show in the list.
• Run the below command to start the execution in the device.
$ adb shell monkey [options] <event-count>

Use monkey tool for testing any UI/application as follows:


• Eg: adb shell monkey -p com.android.contacts -v 1000 //This command will
generate a random stream of 1000 events on the Contacts application.

Presentation Template 12/17/2019 31


UI/Application Exerciser Monkey Tool Contd…

Procedure to run monkey tool on device:


• First connect the device to the system >> Go to the command prompt, check the
device is connected or not.
• Type “adb devices”
• List of connected devices should show in the list.
• Run the below command to start the execution in the device.
$ adb shell monkey [options] <event-count>

Use monkey tool for testing any application.


Eg: adb shell monkey -p com.android.messages -v 1000 //This command will
generate a random stream of 1000 events on the messages application.

Presentation Template 12/17/2019 32


UI/Application Exerciser Monkey Tool Contd…

How to find the packages installed path for the application on your device:
• Once the device is connected, Open the Eclipse Platform.
• Go to Window >> Show View >> Other >> File Explore >> Ok.
• From File Explore, select >> System >> App
• Now we can see the entire “packages installed” path for the application.
• From this, copy the path of the specific application and use it in the command.

Presentation Template 12/17/2019 33


UI/Application Exerciser Monkey Tool Contd…

Advantages:
1. The Monkey is a command-line tool that can run on any emulator instance or on a
device which can user for stress testing on the Application software.
2. If the application crashes or receives any sort of unhandled exception, the Monkey
will stop and report the error.
3. If the application generates an application not responding error, the Monkey will stop
and report the error.
4. Monkey tool can be launch by using a command line on your development machine
or from a script.
5. Using Monkey tool we can set Number of events to attempt.
6. Debugging Options avaliable with monkey tool.
7. Straight-up failures such as crashes, assertion failures, and memory leaks are easy
to detect.
8. Monkey enhances software security and software safety because it often finds odd
oversights and defects which human testers would fail to find, and even careful
human test designers would fail to create tests for.

Presentation Template 12/17/2019 34


UI/Application Exerciser Monkey Tool Contd…

Disadvantages:
1. In monkey tool there are some Operational constraints, such as restricting the test
to a single package.
2. Monkey have poor code coverage; for example, if the input includes a checksum
which is not properly updated to match other random changes, only the checksum
validation code will be verified.
3. Main disadvantage is the cost of developing the monkey, and a limited range of
testing.

More Information:
Refer http://developer.android.com/guide/developing/tools/monkey.html this link for
more information

Presentation Template 12/17/2019 35


THANK YOU

Presentation Template 12/17/2019 36


Presentation Template 12/17/2019 37

Das könnte Ihnen auch gefallen