Search in sources :

Example 96 with Intent

use of android.content.Intent in project materialistic by hidroh.

the class FavoriteActivityTest method testShare.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testShare() {
    TestApplication.addResolver(new Intent(Intent.ACTION_SEND));
    shadowAdapter.getViewHolder(0).itemView.findViewById(R.id.button_more).performClick();
    PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
    Assert.assertNotNull(popupMenu);
    shadowOf(popupMenu).getOnMenuItemClickListener().onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_share));
    assertThat(shadowOf(activity).getNextStartedActivity()).hasAction(Intent.ACTION_SEND);
}
Also used : Intent(android.content.Intent) RoboMenuItem(org.robolectric.fakes.RoboMenuItem) PopupMenu(android.widget.PopupMenu) ShadowPopupMenu(org.robolectric.shadows.ShadowPopupMenu) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) Test(org.junit.Test) TargetApi(android.annotation.TargetApi)

Example 97 with Intent

use of android.content.Intent in project materialistic by hidroh.

the class ItemActivityTest method testFullscreen.

@Config(shadows = { ShadowFloatingActionButton.class })
@Test
public void testFullscreen() {
    Intent intent = new Intent();
    WebItem webItem = new TestWebItem() {

        @Override
        public String getUrl() {
            return "http://example.com";
        }

        @Override
        public String getId() {
            return "1";
        }
    };
    intent.putExtra(ItemActivity.EXTRA_ITEM, webItem);
    controller.withIntent(intent).create().start().resume().visible();
    ShadowFloatingActionButton shadowFab = (ShadowFloatingActionButton) ShadowExtractor.extract(activity.findViewById(R.id.reply_button));
    assertTrue(shadowFab.isVisible());
    ShadowLocalBroadcastManager.getInstance(activity).sendBroadcast(new Intent(WebFragment.ACTION_FULLSCREEN).putExtra(WebFragment.EXTRA_FULLSCREEN, true));
    assertFalse(shadowFab.isVisible());
    ShadowLocalBroadcastManager.getInstance(activity).sendBroadcast(new Intent(WebFragment.ACTION_FULLSCREEN).putExtra(WebFragment.EXTRA_FULLSCREEN, false));
    assertTrue(shadowFab.isVisible());
}
Also used : ShadowFloatingActionButton(io.github.hidroh.materialistic.test.shadow.ShadowFloatingActionButton) TestWebItem(io.github.hidroh.materialistic.test.TestWebItem) WebItem(io.github.hidroh.materialistic.data.WebItem) Intent(android.content.Intent) TestWebItem(io.github.hidroh.materialistic.test.TestWebItem) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 98 with Intent

use of android.content.Intent in project materialistic by hidroh.

the class ItemActivityTest method testFullscreenBackPressed.

@Test
public void testFullscreenBackPressed() {
    Intent intent = new Intent();
    WebItem webItem = new TestWebItem() {

        @Override
        public String getUrl() {
            return "http://example.com";
        }

        @Override
        public String getId() {
            return "1";
        }
    };
    intent.putExtra(ItemActivity.EXTRA_ITEM, webItem);
    controller.withIntent(intent).create().start().resume().visible();
    ShadowLocalBroadcastManager.getInstance(activity).sendBroadcast(new Intent(WebFragment.ACTION_FULLSCREEN).putExtra(WebFragment.EXTRA_FULLSCREEN, true));
    activity.onBackPressed();
    assertThat(activity).isNotFinishing();
    activity.onBackPressed();
    assertThat(activity).isFinishing();
}
Also used : TestWebItem(io.github.hidroh.materialistic.test.TestWebItem) WebItem(io.github.hidroh.materialistic.data.WebItem) Intent(android.content.Intent) TestWebItem(io.github.hidroh.materialistic.test.TestWebItem) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) Test(org.junit.Test)

Example 99 with Intent

use of android.content.Intent in project materialistic by hidroh.

the class ItemActivityTest method testCustomScheme.

@Test
public void testCustomScheme() {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(BuildConfig.APPLICATION_ID + "://item/1"));
    controller.withIntent(intent).create().start().resume();
    verify(hackerNewsClient).getItem(eq("1"), eq(ItemManager.MODE_DEFAULT), any(ResponseListener.class));
}
Also used : Intent(android.content.Intent) ResponseListener(io.github.hidroh.materialistic.data.ResponseListener) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) Test(org.junit.Test)

Example 100 with Intent

use of android.content.Intent in project materialistic by hidroh.

the class ItemActivityTest method testBackPressed.

@Test
public void testBackPressed() {
    Intent intent = new Intent();
    WebItem webItem = new TestWebItem() {

        @Override
        public String getUrl() {
            return "http://example.com";
        }

        @Override
        public String getId() {
            return "1";
        }
    };
    intent.putExtra(ItemActivity.EXTRA_ITEM, webItem);
    controller.withIntent(intent).create().start().resume().visible();
    activity.onKeyDown(KeyEvent.KEYCODE_BACK, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK));
    verify(keyDelegate).setBackInterceptor(any());
    verify(keyDelegate).onKeyDown(anyInt(), any(KeyEvent.class));
}
Also used : KeyEvent(android.view.KeyEvent) TestWebItem(io.github.hidroh.materialistic.test.TestWebItem) WebItem(io.github.hidroh.materialistic.data.WebItem) Intent(android.content.Intent) TestWebItem(io.github.hidroh.materialistic.test.TestWebItem) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) Test(org.junit.Test)

Aggregations

Intent (android.content.Intent)30598 PendingIntent (android.app.PendingIntent)4802 Test (org.junit.Test)2560 View (android.view.View)2527 Bundle (android.os.Bundle)2094 ComponentName (android.content.ComponentName)1706 TextView (android.widget.TextView)1660 Uri (android.net.Uri)1607 Context (android.content.Context)1506 ResolveInfo (android.content.pm.ResolveInfo)1397 PackageManager (android.content.pm.PackageManager)1125 ArrayList (java.util.ArrayList)1067 IntentFilter (android.content.IntentFilter)917 ImageView (android.widget.ImageView)904 ActivityNotFoundException (android.content.ActivityNotFoundException)859 File (java.io.File)823 RemoteException (android.os.RemoteException)786 DialogInterface (android.content.DialogInterface)752 IOException (java.io.IOException)742 SharedPreferences (android.content.SharedPreferences)665