Search in sources :

Example 21 with CursorLoader

use of android.content.CursorLoader in project iosched by google.

the class SessionDetailModelTest method createCursorLoader_NullQuery_ReturnsNullCursor.

@Test
public void createCursorLoader_NullQuery_ReturnsNullCursor() {
    // When ran with mock uri and null query loader id
    CursorLoader createdCursorLoader = (CursorLoader) mSessionDetailModel.createCursorLoader(null, null);
    // Then the returned cursor loader is null
    assertThat(createdCursorLoader, nullValue());
}
Also used : CursorLoader(android.content.CursorLoader) SmallTest(android.test.suitebuilder.annotation.SmallTest) TagMetadataTest(com.google.samples.apps.iosched.model.TagMetadataTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 22 with CursorLoader

use of android.content.CursorLoader in project iosched by google.

the class SessionDetailModelTest method createCursorLoader_SessionQuery_ReturnsCursorLoader.

@Test
public void createCursorLoader_SessionQuery_ReturnsCursorLoader() {
    // Given a mock uri and mock cursor loader
    SessionDetailModel spyModel = spy(new SessionDetailModel(mMockUri, mMockContext, mMockSessionsHelper, mMockLoaderManager));
    doReturn(FAKE_ID).when(spyModel).getSessionId(mMockUri);
    doReturn(mMockCursorLoader).when(spyModel).getCursorLoaderInstance(any(Context.class), any(Uri.class), any(String[].class), any(String.class), any(String[].class), any(String.class));
    // When ran with mock uri and session query loader id
    CursorLoader createdCursorLoader = (CursorLoader) spyModel.createCursorLoader(SessionDetailModel.SessionDetailQueryEnum.SESSIONS, null);
    // Then the returned cursor loader is the mock cursor loader
    assertThat(createdCursorLoader, sameInstance(mMockCursorLoader));
}
Also used : Context(android.content.Context) SettingsMockContext(com.google.samples.apps.iosched.testutils.SettingsMockContext) CursorLoader(android.content.CursorLoader) Matchers.anyString(org.mockito.Matchers.anyString) Uri(android.net.Uri) SmallTest(android.test.suitebuilder.annotation.SmallTest) TagMetadataTest(com.google.samples.apps.iosched.model.TagMetadataTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 23 with CursorLoader

use of android.content.CursorLoader in project iosched by google.

the class SessionDetailModelTest method createCursorLoader_FeedbackQuery_ReturnsCursor.

@Test
public void createCursorLoader_FeedbackQuery_ReturnsCursor() {
    // Given a mock uri and mock cursor loader
    SessionDetailModel spyModel = spy(new SessionDetailModel(mMockUri, mMockContext, mMockSessionsHelper, mMockLoaderManager));
    doReturn(mMockUri).when(spyModel).getFeedbackUri(any(String.class));
    doReturn(mMockCursorLoader).when(spyModel).getCursorLoaderInstance(any(Context.class), any(Uri.class), any(String[].class), any(String.class), any(String[].class), any(String.class));
    // When ran with mock uri and feedback query loader id
    CursorLoader createdCursorLoader = (CursorLoader) spyModel.createCursorLoader(SessionDetailModel.SessionDetailQueryEnum.FEEDBACK, null);
    // Then the returned cursor loader is the mock cursor loader
    assertThat(createdCursorLoader, sameInstance(mMockCursorLoader));
}
Also used : Context(android.content.Context) SettingsMockContext(com.google.samples.apps.iosched.testutils.SettingsMockContext) CursorLoader(android.content.CursorLoader) Matchers.anyString(org.mockito.Matchers.anyString) Uri(android.net.Uri) SmallTest(android.test.suitebuilder.annotation.SmallTest) TagMetadataTest(com.google.samples.apps.iosched.model.TagMetadataTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 24 with CursorLoader

use of android.content.CursorLoader in project iosched by google.

the class VideoLibraryModelTest method createCursorLoader_VideosQuery_Success.

@Test
public void createCursorLoader_VideosQuery_Success() {
    // Given a mock cursor loader set up for a video query
    // When ran with the video query
    CursorLoader createdCursorLoader = (CursorLoader) mSpyModel.createCursorLoader(VideoLibraryModel.VideoLibraryQueryEnum.VIDEOS, null);
    // Then the returned cursor loader is the same as the mock one
    assertThat(createdCursorLoader, sameInstance(mMockCursorLoader));
}
Also used : CursorLoader(android.content.CursorLoader) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 25 with CursorLoader

use of android.content.CursorLoader in project iosched by google.

the class VideoLibraryModelTest method createCursorLoader_FilteredVideosQuery_Success.

@Test
public void createCursorLoader_FilteredVideosQuery_Success() {
    // Given a mock cursor loader set up for a video query
    when(mMockBundle.containsKey(VideoLibraryModel.KEY_TOPIC)).thenReturn(true);
    when(mMockBundle.containsKey(VideoLibraryModel.KEY_YEAR)).thenReturn(true);
    when(mMockBundle.getString(VideoLibraryModel.KEY_TOPIC)).thenReturn("Android");
    when(mMockBundle.getInt(VideoLibraryModel.KEY_YEAR)).thenReturn(2012);
    // When ran with the video query
    CursorLoader createdCursorLoader = (CursorLoader) mSpyModel.createCursorLoader(VideoLibraryModel.VideoLibraryQueryEnum.VIDEOS, mMockBundle);
    // Then the returned cursor loader is the same as the mock one
    assertThat(createdCursorLoader, sameInstance(mMockCursorLoader));
}
Also used : CursorLoader(android.content.CursorLoader) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Aggregations

CursorLoader (android.content.CursorLoader)30 Cursor (android.database.Cursor)12 Uri (android.net.Uri)11 SmallTest (android.test.suitebuilder.annotation.SmallTest)9 Test (org.junit.Test)9 TagMetadataTest (com.google.samples.apps.iosched.model.TagMetadataTest)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 Context (android.content.Context)4 ArrayList (java.util.ArrayList)4 Matchers.anyString (org.mockito.Matchers.anyString)4 SettingsMockContext (com.google.samples.apps.iosched.testutils.SettingsMockContext)3 SuppressLint (android.annotation.SuppressLint)1 Loader (android.content.Loader)1 Bundle (android.os.Bundle)1 MotionEvent (android.view.MotionEvent)1 View (android.view.View)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1 GridView (android.widget.GridView)1 ImageView (android.widget.ImageView)1