forked from priyaaank/RobolectricSample
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
210 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,5 @@ temp.json | |
temp.xml | ||
temp.txt | ||
tmp/ | ||
target/ | ||
target/ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ | |
# project structure. | ||
|
||
# Project target. | ||
target=Google Inc.:Google APIs:9 | ||
target=Google Inc.:Google APIs:10 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+2.66 MB
...bolectric-0.9.7-jar-with-dependencies.jar → ...robolectric-1.0-jar-with-dependencies.jar
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<com.pivotallabs.views.LoadingTextView | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
> | ||
|
||
<include | ||
android:id="@+id/loading_text_spinner" | ||
layout="@layout/loading_view" | ||
android:visibility="visible" | ||
/> | ||
|
||
<TextView | ||
android:id="@+id/loading_text_text_view" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:visibility="invisible" | ||
/> | ||
|
||
</com.pivotallabs.views.LoadingTextView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.pivotallabs.views; | ||
|
||
import android.content.Context; | ||
import android.util.AttributeSet; | ||
import android.view.View; | ||
import android.widget.RelativeLayout; | ||
import android.widget.TextView; | ||
import com.pivotallabs.R; | ||
|
||
public class LoadingTextView extends RelativeLayout { | ||
public LoadingTextView(Context context) { | ||
super(context); | ||
} | ||
|
||
public LoadingTextView(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
public LoadingTextView(Context context, AttributeSet attrs, int defStyle) { | ||
super(context, attrs, defStyle); | ||
} | ||
|
||
public void stopLoadingAndSetText(int text_res_id) { | ||
TextView textView = (TextView) findViewById(R.id.loading_text_text_view); | ||
textView.setText(text_res_id); | ||
textView.setVisibility(View.VISIBLE); | ||
|
||
findViewById(R.id.loading_text_spinner).setVisibility(View.GONE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/test/java/com/pivotallabs/views/LoadingTextViewTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.pivotallabs.views; | ||
|
||
import android.app.Activity; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
import com.pivotallabs.R; | ||
import com.xtremelabs.robolectric.RobolectricTestRunner; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.hamcrest.core.IsEqual.equalTo; | ||
import static org.junit.Assert.assertThat; | ||
|
||
@RunWith(RobolectricTestRunner.class) | ||
public class LoadingTextViewTest { | ||
private LoadingTextView loadingTextView; | ||
private View loadingSpinner; | ||
private TextView loadingTextTextView; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
loadingTextView = (LoadingTextView) LayoutInflater.from(new Activity()).inflate(R.layout.loading_text, null); | ||
loadingSpinner = loadingTextView.findViewById(R.id.loading_text_spinner); | ||
loadingTextTextView = (TextView) loadingTextView.findViewById(R.id.loading_text_text_view); | ||
} | ||
|
||
@Test | ||
public void testStopLoadingAndSetTextShouldHideTheSpinnerAndShowTheTextView() throws Exception { | ||
assertThat(loadingSpinner.getVisibility(), equalTo(View.VISIBLE)); | ||
assertThat(loadingTextTextView.getVisibility(), equalTo(View.INVISIBLE)); | ||
|
||
loadingTextView.stopLoadingAndSetText(R.string.unit_tests_ftw); | ||
|
||
assertThat(loadingSpinner.getVisibility(), equalTo(View.GONE)); | ||
assertThat(loadingTextTextView.getVisibility(), equalTo(View.VISIBLE)); | ||
} | ||
|
||
@Test | ||
public void testStopLoadingAndSEtTextShouldSetTheTextOnTheTextView() { | ||
loadingTextView.stopLoadingAndSetText(R.string.unit_tests_ftw); | ||
|
||
assertThat((String) loadingTextTextView.getText(), equalTo("Unit Tests FTW!!!")); | ||
} | ||
} |