Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Press the button for C2DM Registration.
- Loading branch information
Showing
12 changed files
with
213 additions
and
127 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
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 |
---|---|---|
@@ -1,18 +1,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
android:orientation="vertical" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
android:background="@android:color/white" | ||
> | ||
<TextView | ||
android:id="@+id/title" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
/> | ||
<TextView | ||
android:id="@+id/current_time" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
/> | ||
<TextView | ||
android:id="@+id/title" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:textColor="@android:color/black" | ||
android:textSize="20dip" | ||
android:layout_gravity="center_horizontal" | ||
android:layout_marginBottom="10dip" | ||
android:text="C2DeMo" | ||
/> | ||
|
||
<Button | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/registerButton" | ||
android:text="Register" | ||
/> | ||
|
||
</LinearLayout> | ||
|
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,35 @@ | ||
package com.pivot13; | ||
|
||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import com.google.android.c2dm.C2DMessaging; | ||
import com.google.inject.Inject; | ||
import com.pivot13.util.CurrentTime; | ||
import roboguice.activity.RoboActivity; | ||
import roboguice.inject.InjectView; | ||
|
||
public class HomeActivity extends RoboActivity { | ||
@InjectView(R.id.registerButton) | ||
Button registerButton; | ||
|
||
@Inject | ||
private CurrentTime currentTime; | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.home); | ||
|
||
registerButton.setOnClickListener(new RegisterOnClickListener()); | ||
|
||
|
||
} | ||
|
||
private class RegisterOnClickListener implements View.OnClickListener { | ||
@Override | ||
public void onClick(View v) { | ||
C2DMessaging.register(HomeActivity.this, C2DeMoApplication.C2DM_SENDER_KEY); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,54 @@ | ||
package com.pivot13; | ||
|
||
import android.content.Intent; | ||
import android.os.Parcelable; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
import com.google.inject.Inject; | ||
import com.pivot13.test.support.RobolectricTestRunnerWithInjection; | ||
import com.xtremelabs.robolectric.Robolectric; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import roboguice.inject.InjectView; | ||
|
||
import static com.pivotallabs.robolectricgem.expect.Expect.expect; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
@RunWith(RobolectricTestRunnerWithInjection.class) | ||
public class HomeActivityTest { | ||
@Inject | ||
HomeActivity activity; | ||
|
||
@InjectView(R.id.registerButton) | ||
Button registerButton; | ||
|
||
|
||
@Before | ||
public void setup() throws Exception { | ||
activity.onCreate(null); | ||
} | ||
|
||
@Test | ||
public void shouldHaveATitle() { | ||
final HomeActivity activity = new HomeActivity(); | ||
activity.onCreate(null); | ||
TextView title = (TextView) activity.findViewById(R.id.title); | ||
assertEquals("C2DeMo", title.getText()); | ||
} | ||
|
||
@Test | ||
public void shouldHaveARegisterButton() throws Exception { | ||
expect(registerButton).toBeVisible(); | ||
} | ||
|
||
@Test | ||
public void clickingRegisterButton__shouldRegisterWithC2DMService() throws Exception { | ||
expect(Robolectric.getShadowApplication().peekNextStartedService()).toBeNull(); | ||
Robolectric.clickOn(registerButton); | ||
Intent intent = Robolectric.getShadowApplication().peekNextStartedService(); | ||
expect(intent.<Parcelable>getParcelableExtra("app")).not.toBeNull(); | ||
expect(intent.getStringExtra("sender")).toEqual(C2DeMoApplication.C2DM_SENDER_KEY); | ||
expect(intent.getAction()).toEqual("com.google.android.c2dm.intent.REGISTER"); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.