Android :: How Can I Unit Test Activity That Acts On Accelerometer?

May 10, 2010

I am starting with an Activity based off of this ShakeActivity and I want to write some unit tests for it. I have written some small unit tests for Android activities before but I'm not sure where to start here. I want to feed the accelerometer some different values and test how the activity responds to it. For now I'm keeping it simple and just updating a private int counter variable and a TextView when a "shake" event happens. So my question largely boils down to this: How can I send fake data to the accelerometer from a unit test?

Android :: How can I unit test Activity that acts on Accelerometer?


Android :: Error When Unit Test With Activity Instrumentation Test Cas­e 2?

Aug 23, 2009

I am using ActivityInstrumentationTestCase2 to do some test for an activity. I get a button in the setUp() method like this: protected void setUp() throws Exception {super.setUp(); act = getActivity(); btn = Button)act.find ViewById ( R.id.bike_button ); // this button has been defined in layout} Then I use this button to perform a click in a test method like this: public void testBikeButton(){ //click the bike button btn.performClick();}

View 7 Replies View Related

Android :: Get Dorid Unit Test Instrementation To Call Activity's OnActivityResult()?

Feb 3, 2009

Can you please tell me if you know how to get the Andorid unit test instrementation to call my activity's onActivityResult()?

I can't find anything here: http://code.google.com/android/reference/android/app/Instrumentation.

View 4 Replies View Related

Android :: How To Transfer Test Fixture File To Device From Unit Test Application?

Sep 24, 2010

I'm writing an Android JUnit test and want to copy/reset a test fixture file (it's an SQLite database file.) If I were within the main application, I know I could just place the file in the assets directory and use getResources().getAssets().open(sourceFile).However, this API appears to be unavailable from the ActivityInstrumentationTestCase2 class.Is there an easy way to copy a file over from the testing PC, or should I just keep a fresh copy of a test fixture on the device and copy it over a temporary file?

View 2 Replies View Related

Android :: Is It Unit Test Or An Integration Test?

Nov 9, 2010

I'm working on a school project and I'm researching testing possibilities for Android applications. On this page: http: // developer . android . com/ resources / tutorials /testing /hello android. Google writes about a unit test. Is this really a unit test? A Unit test will not integrate all classes and will not test in his context. So my opinion is it is not a Unit Test but an Integration Test.

View 7 Replies View Related

Android :: Way To Unit Test Phone Library App?

Nov 16, 2010

Sorry if this is a bit of a vague question, however im struggling to find a single solid example on how to do unit testing (isolated testing) with Android. So one project contains models and logic, then another project contains tests for said library. There is no front end or UI, so I want to do the bare minimum to just be able to test that my methods all work in isolation.

View 1 Replies View Related

Android :: Unit Test Build Error

Mar 8, 2010

I just switched the way my Android project is being built and non of my unit tests work any more...I get errors like WARN/dalvikvm(575): VFY: unable to resolve static field X in WARN/dalvikvm(575): VFY: unable to find class referenced in signature These errors only come from my Unit Tests, where classes defined in it can't even see other classes defined in the unit test. Before each project had it's own directory with copies of the 3rd party jar files. I've read around that Dex does weird things with references but haven't been able to figure out how to fix this problem. Is there a better way to do this? I would love to see an example of a large Android workspace where there are multiple projects, jar references, etc.Is it possible to fix this with an Order/Export tweak ?

View 3 Replies View Related

Android :: Author Unit Test Case

Oct 23, 2009

I have downloaded donut branch and build for emulator. I am running the author test case in the following way cd /data;test_pvauthorengine -test 5 5 -video yuvtestinput.yuv - videoconfigfile mp4_config.cfg -audio amrtestinput.amr - audioconfigfile amr_config.cfg -output mp4.3gp Starting Test 5: AMR & YUV to AV using M4V Encoder .3gp Test PVSCHED:Scheduler 'PVAuthorEngineTestScheduler', Thread 0xafe43c24: Error! AO PvmiMIOFileInput Error 101 not handled PVSCHED:Scheduler 'PVAuthorEngineTestScheduler', Thread 0xafe43c24: Error! Reason 101

View 3 Replies View Related

Android :: Unit Testing With Test Only Assets

Jul 3, 2009

I my main app and tests are organized like this (standard from "android create project"): AndroidManifest.xml assets/ main app asset files src/tests/AndroidManifest.xml -- uses <instrumentation> to point to the main app assets/ -- test-specific asset files src/ Writing test cases with AndroidTestCase, I'd like to load asset files from the test-specific assets/ directory, not from the main app assets/ directory. How can I accomplish that? The normal way to load an asset would be getContext().getAssets().open ("foo.txt"), for assets/foo.txt in the main app. I assume I just have to somehow change the Context or the AssetManager to point to the test- specific assets directory, but I don't see any way to do that. I have looked into the tests/bin/MyApp-debug.apk to confirm that the test assets are in there. Now I just need a way to access them.

View 2 Replies View Related

Android :: How To Refactor Class So I Can Unit Test It?

May 21, 2010

I am trying to unit test a class that does SAX parsing and creates an object.This class takes a string as a parameter representing the URL of a document on the internet, parses it and then creates an object based on the contents.I don't want to have the unit tests actually access the network, so I'd like to have a few test xml files to parse. However I can't figure out how to access them from my AndroidTestCases. I don't want to include the test files with the actual application, I want them in the test project (it's a separate project, as is the norm for Android tests from what I could gather - due to the need to have a custom AndroidManifest.xml, for one).One way would be to put the XML files in the test project's assets directory, I can read them using getContext() .getAssets().open(filename) into an InputStream in the test case, but my class expects a URL string. I'd rather not have to provide an InputStream to this class instead of the current URL string. I can test just the parsing by making two methods, one that takes a string and one an Inputstream, and test the second, but how can I then test the one that just takes a string?How should I design my class and or tests to circumvent this problem?

View 1 Replies View Related

Android :: Unnecessarily Hard To Unit Test?

Oct 8, 2009

Being able to write Android apps in regular Java is a huge win. However, I am confused about unit testing Android apps. Many of the 'best practices' seem to boil down to 'split your business logic off, and test it separately using JUnit'. This is great as far as it goes. And I understand that truly testing the UI will require firing up the emulator. But it seems there is a category of UI tests that I should be able to run without the emulator. The various Mockxxx classes seem to be going a long way towards this. But why (oh why oh why!) do they all. throw new RuntimeException( "Stub!" ); in their constructors? I can understand them doing this in their METHODS (then I could subclass them as needed) but why their constructors? I cannot stop this functionality so I cannot do (limited but useful) UI tests such as public TextView createTextView ( Context context ) {return new TextView( context );

View 3 Replies View Related

Android :: Add New Id To R.id To Later Reference It Via FindViewById() In Unit Test?

Jul 9, 2010

I am creating an EditText object which i then try to reference in a unit test. what is the best way to add a new 'id' to R.id for this dynamically created object so that i can later reference it via findViewById() in the unit test?

View 2 Replies View Related

Android :: Writing Unit Test For Parcelable Object

Feb 6, 2009

I follow the following example in creating a Parcelable object: http://code.google.com/android /reference / android /os / Parcelable .html . Writing unit test for parcelable object

View 4 Replies View Related

Android :: Relative Layout Unit Test Setup

Mar 20, 2010

i'm trying to write an unit test for my Android's RelativeLayout. Currently, my testcode setup is as follow:public class SampleRelativeLayoutTest extends AndroidTestCase {private ViewGroup testView;private ImageView icon;private TextView title;@Overrideprotected void setUp() throws Exception {super.setUp();
// inflate the layout
final Context context = getContext();
final LayoutInflater inflater = LayoutInflater.from(context);
testView = (ViewGroup) inflater.inflate(R.layout.sample_layout,
null);
// manually measure and layout
testView.measure(500, 500);
testView.layout(0, 0, 500, 500);
// init variables
icon = (ImageView) testView.findViewById(R.id.icon);
title = (TextView) testView.findViewById(R.id.title);
}However, I encountered NullPointerException with the following stack tracejava.lang.NullPointerException
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:427)
at android.view.View.measure(View.java:7964)
at com.dqminh.test.view.SampleRelativeLayoutTest.setUp(SampleRelativeLayoutTest.java:33)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
What should I change in my setUp() code to make the test run properly ?

View 1 Replies View Related

Android :: Good Automated Unit And System Test Tools?

Nov 3, 2010

I approached this problem as an oh hey that's not too bad, I can write a bunch of unit tests, and I have been keeping my suite green. However as things get more involved continuous integration and testing is a great great thing to have. And then I saw oh Android has emma integration as well awesome ... and then that's where it get's iffy. So I setup Hudson and have it call the coverage target of the ant build.xml that the android executable in the sdk can generate. And then it hits me. adb -s <emulator> shell am instrument -w ... will never return a result code that is not 0 ... because adb technically exited cleanly and usually will regardless of how the shell command that executed did..............

View 6 Replies View Related

Android :: How Do I Sync Message Queue Thread In Unit Test?

Mar 30, 2010

I'm writing unit tests for a ListActivity in Android that uses a handler to update a ListAdapter. While my activity works in the Android emulator, running the same code in a unit test doesn't update my adapter: calls to sendEmptyMessage do not call handleMessage in my activity's Handler. How do I get my ActivityUnitTestCase to sync with the MessageQueue thread and call my Handler?

View 2 Replies View Related

Android :: How Can I Source-level Debugging In Unit Test Caes In Android Under Eclipse With ADT?

Feb 2, 2009

I can run the unit test cases either by :

1. command line ' adb shell am instrument -w com.example.android.apis.tests/android.test.InstrumentationTestRunner'

2. Go to 'Dev' and clicks 'Instrumentation' and click 'Test API Demo'.But my questions now is, how can I debug my unit test cases? I try 'Debug' my APIDemoTest eclipse project and then do #2 above, it did not break at any of my breakpoints I setup.

View 3 Replies View Related

Android :: Test Data Sources In Android Unit Testing

Jan 27, 2010

I want to test parsing of data returned from server.I thought I might create several test XML files and then feed them to the sax parser which uses my custom data handler (as in the application that I test).But where should I put those test XMLs?I tried with [project_root] /res/xml, but then I get the error: android.content.res.Resources $NotFoundException: Resource ID #0x7f040000 type #0x1c is not valid at android.content. res. Resources. loadXml ResourceParser(Resources.java:1870)at android.content.res. Resources. getXml(Resources. java:779) Does that mean that the xml is invalid, or that android couldn't find the XML file?(I use the same XML that comes from the server - copied it from the firebug's net panel and pasted into the file).Can I somehow read that XML as a text file, since etContext(). getResources() .getXml (R.xml.test_response1) returns XmlResourceParser instead of String (which I'd prefer)?

View 1 Replies View Related

Android :: How To Start Android Test Unit From Command Line?

Nov 16, 2010

Here is my manifest file:<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=" http://schemas. android. com /apk/res/android" package="com. wsandroid.test" android:version Code= "1" android:versionName="1.0"><application android:icon="@drawable/icon" android : label ="@string/app_name"><uses-library android:name="android.test.runner" /></application> <uses-sdk android:minSdkVersion="3" /><instrumentation android:targetPackage="com.wsandroid" android :name="android.test.InstrumentationTestRunner" />

View 1 Replies View Related

Android :: Sounds + Accelerometer - Weird Accelerometer Values - BUG?

Jun 9, 2009

I am developing a game. In which the user controls movement using the accelerometer. Sounds effects can also be enabled. However when laying the phone flat down and playing the game without the accelerometer gives nice 0,0,0 values. However when play WITH SOUNDS on, i get a buch of weird values: while the phone is NOT moving.

This is really a big bug that makes life hard for Game Developers. I tried to take an avarge of the last 5 values from the sensor.. but this is not enough.. The harder the sounds plays: the higher the weird sensor values. When using the headphones: almost no weird values. Seems that sounds interferes with the accelerometer sensor.

View 5 Replies View Related

Android :: Pass Bundle To An Activity On An Instrumentation Test Case

Jan 29, 2009

When implementing an ActivityInstrumentationTestCase, how do you start the activity with a Bundle of saved state?

View 2 Replies View Related

Android :: Where To Get App That Acts Same Way As D-LINK Media Player?

Nov 13, 2010

I love sharing "steam" my media content in my household. I have a D-LINK DSM-510 to steam videos (movies), photos, and music to my TV. Is there an app for andriod that acts the same way as my D-LINK media player that I can do the same with my Google G1 android mobile phone, or any other type of android phones, I know mine is old and outdated.

View 7 Replies View Related

General :: Keyguard Test Activity Has Stopped

May 20, 2014

I'm editing a stock rom retail BR 4.4.2 of Moto X. I needed edit the SystemUI.apk for add a feature, and for this i should add a line in the AndroidManifest.xml, when i did all the modifications and install the rom, i get this message "KeyguardTestActivity has stopped". I have identified that the problem stay in the modification in the AndroidManifest.xml, and the "KeyguardTestActivity" is the app Keyguard.apk that is the lockscreen. I don't know why this don't work! I'm using the last apktool, i have installed the framework-res.apk of the stock rom!

View 1 Replies View Related

HTC EVO 4G :: Swype Keyboard Acts Erratic / When Plugged Into Charger

Jul 5, 2010

When the phone is plugged into the ac charger, swype acts erratic when using it, as soon as I unplug from the charger, it swypes smoothly. Can someone verify this?

View 5 Replies View Related

HTC Desire : Gmail Push Or Email Notification Acts Weird

Apr 16, 2010

I'm setting up my new desire, and gmail works just fine, but the push email or email notification perhaps rather, is acting kind of irrational.

First when I set it up it would go off at about the same time as my email checker on my computer using imap idle. On the second email arriving though there is no more notification from the desire phone, this may be a feature although a weird one. Now I go into the inbox on the desire and delete the 2 emails in question and exit. The next time an email arrives the phone will react but not nearly as fast, it can be minutes or even more.

View 2 Replies View Related

HTC Droid Eris :: When Try Texting In Portrait Mode - Acts As If My Trackball Is Stuck To Left?

Apr 2, 2010

So when I try texting in Portrait mode, it acts as if my trackball is stuck to the left, now I used to have this problem only when it was charging, but now it's more often.

Also on my home pages, it will slide all the way to the far left one. And sometimes my messaging app will lag, then force close.

View 5 Replies View Related

Android :: Getting Test Run Failed No Test Results?

Aug 11, 2010

I have never used JUnit before, and now I'm trying to set it up on an Android project.My project under test is fairly complex, including some JNI, but my test project, at the moment, is completely trivial. I have found many examples (that look totally different) online of how to make a test project, but it seems that no matter which one I follow, I get the same results.Here's my JUnit project code:package com.mycompany.myproject.test;
import android.test.AndroidTestCase;public class SimpleTestCaseExample extends Android TestCase {public void test_testOne() {fail("Just Always Fail");When I run, I see the following in Logcat:
stdout INSTRUMENTATION_STATUS: numtests=2
stdout INSTRUMENTATION_STATUS: test=test_testOne
stdout INSTRUMENTATION_STATUS_CODE: 0
stdout INSTRUMENTATION_STATUS: id=InstrumentationTestRunner
stdout INSTRUMENTATION_STATUS: current=2
stdout INSTRUMENTATION_STATUS: class=com.mycompany.myproject.test.SimpleTestCaseExample
stdout INSTRUMENTATION_STATUS: stream=
stdout INSTRUMENTATION_STATUS: numtests=2
stdout INSTRUMENTATION_STATUS: test=testAndroidTestCaseSetupProperly
stdout INSTRUMENTATION_STATUS_CODE: 1
stdout INSTRUMENTATION_STATUS: id=InstrumentationTestRunner
stdout INSTRUMENTATION_STATUS: current=2
stdout INSTRUMENTATION_STATUS: class=com.mycompany.myproject.test.SimpleTestCaseExample
stdout INSTRUMENTATION_STATUS: stream=.
stdout INSTRUMENTATION_STATUS: numtests=2
stdout INSTRUMENTATION_STATUS: test=testAndroidTestCaseSetupProperly
stdout INSTRUMENTATION_STATUS_CODE: 0
stdout INSTRUMENTATION_RESULT: stream=
stdout Test results for InstrumentationTestRunner=..
stdout Time: 0.07
stdout OK (2 tests)
stdout INSTRUMENTATION_CODE: -1
But, I get the following in the Console:Launching instrumentation android.test. Instrumentation TestRunner on device emulator-5554 Collecting test information Test run failed: No test results I have tried a variety of different things, messing with the basic TestCase class, or the TestSuite class, or a variety of other options. I tried to just go for the most trivial example because I'm really still trying to learn how this works.Whatever I try, I see this error.

View 1 Replies View Related

Motorola Droid X :: Touchscreen Test - Drawing Lines Test

Jul 15, 2010

One more video about the fancy touchscreen of the Droid X. This one has happier results! Check it out at the link below.Droid X Touchscreen Test See you later. you'll know why this post is short when you read the blog. running downstairs!

View 5 Replies View Related

Missing Target Class To Test In Test Application?

Nov 10, 2011

I have a project (that compiles and runs in the emulator.) I have a test project that tests part of this project. This test project also compiles with no problems, but when I try to run (test) it in the emulator, I get a NoClassDefFoundError exception on one of the classes my test class tests (I hope that made sense!) when it starts to run in the emulator. This is coming out of the adb log. I looked in the bin directory (of the test project) for the missing class, but could not find it... Should it be there? I found no reference (apk, etc) of the project I am trying to test either in the test projects bin directory. How does the test project get the classes it needs to test against (in the classpath, I assume.) How do the tested classes get moved to the emulator? I did try running the app before testing, so I know it is installed and runs correctly. BTW, I am using netbeans with the nbandroid plugin.

View 1 Replies View Related

Android :: Android And Junit Reports Test Run Failed - No Test Results

Jul 16, 2010

I am unable to integrate Junit with Android. I am using Junit 3, I have also tried Junit4.
package* com.android.test;
import* com.android.MyActivity;
import* android.app.Activity; *
import* android.test.ActivityInstrumentationTestCase2;
public* *class* TestMyView *extends *
ActivityInstrumentationTestCase2<MyActivity> {
Activity myActivity ;
*public* TestMyView(String pkg, Class<MyActivity> activityClass) {
*super*(pkg, activityClass);
myActivity = getActivity() ;

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved