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 ?

Android :: Relative Layout Unit Test setup


How To Setup Scrollview With Relative Layout

Feb 22, 2012

I am having an issue trying to setup a scrollview with a relative layout.

Here is my layout file

Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

[Code]...

The scrollview is working correctly but the relativelayout is showing up correctly in my graphical layout view but I can't seem to see it on my phone or emulator. I want it to be displayed all the time and not a part of the scrollview. I just don't know how to fix it.

Here is how I would like it to work

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 :: 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 :: How To Place Relative Layout At Bottom Of Screen - Or Linear Layout

Sep 27, 2010

I have following in xml

I wanna put the second linear layout at the bottom of the screen.

I have set the property of second Relative layout to bottom but still not showing at bottom..

code:...................

View 2 Replies View Related

Android :: Can I Do This Entire Layout With Relative Layout?

May 4, 2010

Here's a screen shot of the layout I'm looking for: http://www.vimtips.org/media/ll.png Can this all be done with one Relative Layout?

View 1 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 :: 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 :: Android - Nesting Relative Layout Inside Linear Layout

Oct 15, 2010

I have the following code in my layout.xml.

code:............

In the eclipse Plugin layout creator, the EditText and button are shown properly. (see the below screenshot)

But on the device and emulator, the button is not hidden. (see the below screenshot)

why the button is getting hidden in the device?

View 3 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 :: Relative Layout And Include Tag

Jun 14, 2009

I'm reworking some of my layouts to use Relative layout. I have some building blocks which I'd like to reuse. The problem I seems to have with the include of the layout and position other layouts out of this include. Example:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height=wrap_content"

View 2 Replies View Related

Android :: Specifying Relative Positions In Layout?

Sep 30, 2009

I need to implement a screen containing a list of blocks one below the other. Each block will contain mutiple superimpose elements (Images, text) for which the relative position needs to be specified with respect to the top left corner of the block.

For creating the list of blocks i have used listview. For each block i tried to use relative layout.This works ok when the phone is in landscape mode and absolute position is specified relative to left edge of the phone. But when the phone is put in the portrait mode the layout gets distorted.

1) What layout can be used for this scenario?

2) Can relative positions be specified in terms of percentage of screen width/height instead of pixels?

View 3 Replies View Related

Android :: Main Use Of Relative Layout?

Dec 22, 2009

What is the main use of relative layout?

View 3 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 :: Understanding Relative Layout - Add Four Controls

May 19, 2010

I'm attempting to add four controls to a layout; <label> <text> <seek> <radio> I want the seek widget to occupy all the available screen space between the edittext control and the radio control. However if I give it the value android:layout_width="wrap_content" only a small seek control is displayed and if I set the value to fill_parent it overwrites the radio control. I would have thought there would be a mechanism to occupy the free space between the text and radio controls dynamically. The xml file I am using is below You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

View 2 Replies View Related

Android :: Get Width Of Linear / Relative Layout?

Nov 19, 2010

Is it possible to get the width of a linear/relative layout, if the layout_width is set to fill_parent in the layout xml? For example, I have the following layout xml. Is it possible to find the width of the cameraSourceScreen?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/CameraSourcesScreen"
><LinearLayout android:id="@+id/button_bar"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:background="@drawable/topbar"
android:orientation="horizontal"
android:gravity="center">.......

View 1 Replies View Related

Android :: How To Define Height Of A Button In Relative Layout?

Nov 24, 2010

I have a button on a relative layout that hugs the buttom of the parent, but since there is not much above the button, the height of it is massive and extends to the object above it.What kind of code can I use to make sure the button stays at a normal height while still hugging the bottom of the parent?

View 1 Replies View Related

Android :: Relative Layout And Button To The Left Of TextView

Jan 22, 2010

In a RelativeLayout I have a Button to the right of a TextView. The problem is that the text view gets squished to the left of the screen.I want the Button to be squished to the right and the TextView take up all the remaining space.I can't use 'Fill Layout' on the TextView because the button then gets removed from the View completely.

View 1 Replies View Related

MotionEvent And Relative Layout?

Nov 24, 2011

I have a relative layout built from XML.I am capturing the onTouchEvent.When I touch the screen anywhere except over the TableLayout or ImageButton

the MotionEvent.ACTION_DOWN and MotionEvent.ACTION_MOVE

events work fine.

how to make the onTouchEvent() work on the TableLayout and ImageButton views?

The purpose of the exercise was to have a drag method working over the relative layout,no

Maybe manipulating the layout_margin values? I was contemplating a transparent canvas overlay but haven't figured that out yet.

Code snippets below

XML
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"[code]......

View 2 Replies View Related

Android :: Relative Layout Height To Fill Remaining Space

Sep 9, 2010

I have the following layout in my xml file:

<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout android:id="@+id/logoLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
-- some images </FrameLayout>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:layout_below="@+id/logoLayout">

Button 1
Button 2
Button 3
Button 4

</RelativeLayout>
<RelativeLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_alignParentBottom="true">

Button 5
</RelativeLayout>
<RelativeLayout>

Maybe I didn't do it in the best way. What I want: have the Layout that contains the 4 buttons to use the entire space between the top and bottom layout, and I want to have the button equally arranged in the layout. Something like this:
http://img16.imageshack.us/i/androidq.png/

I add the whole layout code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background">

<!--The header of the page-->
<FrameLayout android:id="@+id/logoLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView android:id="@+id/logoBackground"
android:src="@drawable/logo_background_small"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>

<ImageView android:id="@+id/logoImage"
android:src="@drawable/logo_small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:gravity="center"
android:padding="3dip"/>

<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/tracks"
android:layout_gravity="center"
android:gravity="right"
android:textSize="22dip"
android:textColor="#ffffff"
android:padding="3dip">

</TextView>
</FrameLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:layout_below="@+id/logoLayout">

<Button android:id="@+id/btn1"
android:layout_height="wrap_content"
android:layout_width="250dip"
android:drawableLeft="@drawable/img_small_btn_look_around"
android:background="@drawable/main_long_menu_button"
android:text="@string/btn1"
android:textSize="18dip"
android:textColor="#ffffff"
android:layout_marginTop="20dip"
android:onClick="btnMyTracksOnClick">
</Button> <Button android:id="@+id/btn2"
android:layout_height="wrap_content"
android:layout_width="250dip"
android:drawableLeft="@drawable/img_small_btn_look_around"
android:background="@drawable/main_long_menu_button"
android:text="@string/btn2"
android:textSize="18dip"
android:textColor="#ffffff"
android:layout_marginTop="20dip"
android:layout_below="@+id/btn1">
</Button>
<Button android:id="@+id/btn3"
android:layout_height="wrap_content"
android:layout_width="250dip"
android:drawableLeft="@drawable/img_small_btn_look_around"
android:background="@drawable/main_long_menu_button"
android:text="@string/btn3"
android:textSize="18dip"
android:textColor="#ffffff"
android:layout_marginTop="20dip"
android:layout_below="@+id/btn2">
</Button>
<Button android:id="@+id/btn4"
android:layout_height="wrap_content"
android:layout_width="250dip"
android:drawableLeft="@drawable/img_small_btn_look_around"
android:background="@drawable/main_long_menu_button"
android:text="@string/btn4"
android:textSize="18dip"
android:textColor="#ffffff"
android:layout_marginTop="20dip"
android:layout_below="@+id/bt3">
</Button> </RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_alignParentBottom="true"
<Button android:layout_width="90dip"
android:layout_height="wrap_content"
android:textSize="20dip"
android:textColor="#ffffff"
android:layout_alignParentLeft="true"
android:background="@drawable/sett_menu_button"
android:text="@string/back"
android:layout_marginLeft="3dip"/>
</RelativeLayout>
</RelativeLayout>

View 2 Replies View Related

Android :: How To Make Edit Text Within A Relative Layout Wrap?

Jul 14, 2009

How do I make multiline EditText within a Relative Layout wrap the lines of text that were entered? I want the user to enter one line of text without allowing line breaks, but show it broken up by words into multiple lines inside a rather smallish, square EditText window.

View 3 Replies View Related







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