Search in sources :

Example 1 with TestWebItem

use of io.github.hidroh.materialistic.test.TestWebItem 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 2 with TestWebItem

use of io.github.hidroh.materialistic.test.TestWebItem 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 3 with TestWebItem

use of io.github.hidroh.materialistic.test.TestWebItem 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)

Example 4 with TestWebItem

use of io.github.hidroh.materialistic.test.TestWebItem in project materialistic by hidroh.

the class BaseListActivityTest method testSelectItemOpenItem.

@Test
public void testSelectItemOpenItem() {
    PreferenceManager.getDefaultSharedPreferences(activity).edit().putString(activity.getString(R.string.pref_story_display), activity.getString(R.string.pref_story_display_value_comments)).commit();
    controller.pause().resume();
    activity.onItemSelected(new TestWebItem() {

        @Override
        public String getId() {
            return "1";
        }
    });
    assertEquals(ItemActivity.class.getName(), shadowOf(activity).getNextStartedActivity().getComponent().getClassName());
}
Also used : TestWebItem(io.github.hidroh.materialistic.test.TestWebItem) Test(org.junit.Test) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest)

Example 5 with TestWebItem

use of io.github.hidroh.materialistic.test.TestWebItem in project materialistic by hidroh.

the class BaseListActivityTest method testGetSelectedItem.

@Test
public void testGetSelectedItem() {
    activity.onItemSelected(new TestWebItem() {

        @Override
        public boolean isStoryType() {
            return true;
        }

        @Override
        public String getId() {
            return "1";
        }
    });
    assertNotNull(activity.getSelectedItem());
}
Also used : TestWebItem(io.github.hidroh.materialistic.test.TestWebItem) Test(org.junit.Test) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest)

Aggregations

TestWebItem (io.github.hidroh.materialistic.test.TestWebItem)15 Test (org.junit.Test)13 Intent (android.content.Intent)10 SlowTest (io.github.hidroh.materialistic.test.suite.SlowTest)10 WebItem (io.github.hidroh.materialistic.data.WebItem)6 RobolectricPackageManager (org.robolectric.res.builder.RobolectricPackageManager)3 ConnectivityManager (android.net.ConnectivityManager)2 Bundle (android.os.Bundle)2 KeyEvent (android.view.KeyEvent)2 WebView (android.webkit.WebView)2 TestItem (io.github.hidroh.materialistic.test.TestItem)2 TestReadabilityActivity (io.github.hidroh.materialistic.test.TestReadabilityActivity)2 Before (org.junit.Before)2 Config (org.robolectric.annotation.Config)2 ShadowWebView (org.robolectric.shadows.ShadowWebView)2 Account (android.accounts.Account)1 AppBarLayout (android.support.design.widget.AppBarLayout)1 Fragment (android.support.v4.app.Fragment)1 BuildConfig (io.github.hidroh.materialistic.BuildConfig)1 ShadowFloatingActionButton (io.github.hidroh.materialistic.test.shadow.ShadowFloatingActionButton)1