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?

Android :: How do I sync Message Queue thread in unit test?


Android :: How To Pause A Thread's Message Queue?

Oct 7, 2010

I am queuing up a bunch of runnables into a thread via a Handler.post(). I would like the ability to send a note to that thread that it should pause. By pause I mean, finish the runnable or message you are currently working on, but don't go to the next message or runnable in your message queue until I tell you to continue.

View 2 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 :: 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 :: 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 :: 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?

View 3 Replies View Related

Android :: Handler Class And The Timing Of When Its Message Queue Is Emptied

Sep 6, 2010

I was curious about the nature of the handleMessage() and sendMessage() behavior of the Handler class. I want to be able to send message to another thread in such a way that the destination thread can process the message queue when it wants to. It seems, however, that the message is processed by handleMessage() practically as soon as it's sent.

I'm trying to design a game loop thread that does something like this:

CODE:.....

However, I as soon as sendMessage() is called (from the parent/calling thread), the Handler.handleMessage() is processed (in the child/receiving thread), even if the child/receiving thread is blocking in a while loop.

I've seen this problem solved in other games by using a thread-safe list (ConcurrentLinkedQueue). The UI thread just posts events to this queue, and the game loop can remove the events as it seems fit. I just assumed the Handler class was designed for this purpose. It seems it's more intended for asynchronous callbacks to the parent thread.

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 :: 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 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 :: How To Test For The Appearance Of A Toast Message

Mar 8, 2010

Would anyone know how to test for the appearance of a Toast message on an Activity? I'm using code similar to what the OP posted on this question for testing my program flow from one activity to the next. I'd also like to be able to test for toast messages on particular activities.

View 2 Replies View Related

HTC Droid Eris :: Show Message In Notification Bar But Text Of Message Will Not Appear In Text Thread

Jun 3, 2010

Sometimes when I receive messages it makes the notification sound and will show message in notification bar but the text of the message will not appear in the text thread. Used to happen every once in a while, now doing it multiple times a day. I use Handcent but I doubt that is the problem because the messages dont show up in the regular messaging either. Just want to see if i am alone with this problem.

View 8 Replies View Related

Android :: Opens At The Oldest Thread Message

Aug 4, 2010

Not sure if this is a common problem, but essentially, in the bundled 'Messages' application for the HTC Legend, the text messages are saved as a thread as standard. But today, for some bizarre reason, when I open a message thread, it opens at the oldest message, whereas before, it would open at the most recent message. I've looked around in the settings, turned my phone on and off, cleared the data, but still can't get it to revert, it's quite annoying to scroll through hundreds of messages to get to the most recent SMS.

View 1 Replies View Related

Android :: Getting Thread ID / Phone# Of An Open SMS Message?

Sep 21, 2010

I am using RunningTaskInfo.topActivity.getClassName() to determine the class name of the activity being viewed by the user. If the top activity is an sms message (the user is texting) then I want to determine either the thread id of the open message or the contact name/ number, either will work! I am able to determine if a message is open by comparing the class name.unningTaskInfo.topActivity.getClassName().equals("com.android.mms.ui.Compo­seMessageActivity") which returns true/false. When it is true I need to get the above information from this "compose message". Any ideas on how I can get this kind of information from an Android OS activity (an sms message)?

View 3 Replies View Related

Android :: Text Message Thread To Email

Sep 24, 2009

is there an app to copy a complete text thread and email?

View 1 Replies View Related

Android :: Java Thread Message Passing

Jun 16, 2010

I'm writing an Android app. I have a main method, which creates and runs a new Thread using an anonymous inner Runnable class. The run() method, when it's done, calls a method on it's parent class (in the main thread) that calls notifyDataSetChanged() so that the main thread can redraw the new data. This is causing all kinds of trouble (ViewRoot$CalledFromWrongThreadException). The thing is, this method being called from the worker thread is on the class that's created in the UI thread. Shouldn't that be running on the UI thread? Or am I missing something.

View 1 Replies View Related

Android :: Posting Toast Message From A Thread

Nov 17, 2010

My application launches a thread to query the web for some data. I want to display a Toast message when nothing is found, but my application always crashes. I've tried using the application Context from within the thread, like so: Toast.makeText(getApplicationContext(), "testttt", Toast.LENGTH_LONG).show(); I've also tried creating a Runnable with the Toast call and calling runOnUiThread(runnable) from the Thread (the Toast call in this runnable uses the Activity as the first parameter). Does anyone have any ideas on how to accomplish this?

View 3 Replies View Related

Android :: Thread Loses Message After Wait And Notify

Apr 19, 2010

I have a problem handling messages in a Thread. My run-method looks like this The problem is that the run-method logs "id from message: null" though "message ID" has a value in the Log-statement. Why does the message "lose" it's data when being send to the thread? Has it something to do with the notify?

View 1 Replies View Related

Android :: Handler Fails To Deliver Message / Run Able To Main Thread

Feb 18, 2010

I have an app with a two threads - main and data loader. When data loader finishes it posts a Runnable object to the main thread (as described in the DevGuide), but it never gets delivered and run. Here's the basic code:

class MyApp extends Application{
public void onCreate()
{LoaderThread t = new LoaderThread();
t.start(); }
private class LoaderThread extends Thread {
public void run()
{ SystemClock.sleep(2000);
boolean res = m_handler.post(m_runnable);
if(res)
Log.d(TAG, "Posted Runnable"); } ............

View 2 Replies View Related







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