Search in sources :

Example 1 with Content

use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.

the class ContentSearchFragmentTest method initContentContainer.

/**
 * This helper method will setup the test content container.
 */
private void initContentContainer() {
    // Create three items of content
    Content item1 = new Content();
    item1.setId("2323");
    item1.setTitle("Cooking Show 1");
    item1.setDescription("a great cooking show!");
    item1.setExtraValue("duration", "358");
    item1.setCardImageUrl("http://www.gstatic.com/webp/gallery/5.jpg");
    item1.setUrl("http://html5demos.com/assets/dizzy.mp4");
    item1.setExtraValue("categories", new ArrayList<>(Collections.singletonList("International Cuisine")));
    item1.setExtraValue("channelId", 6341);
    Content item2 = new Content();
    item2.setId("232323");
    item2.setTitle("Cooking Show 2");
    item2.setDescription("a better cooking show!");
    item1.setExtraValue("duration", "358");
    item2.setCardImageUrl("http://www.gstatic.com/webp/gallery/5.jpg");
    item2.setUrl("http://html5demos.com/assets/dizzy.mp4");
    item2.setExtraValue("categories", new ArrayList<>(Collections.singletonList("International Cuisine")));
    item2.setExtraValue("channelId", 6341);
    Content item3 = new Content();
    item3.setId("232323232");
    item3.setTitle("Penne arrabbiata");
    item3.setDescription("A cooking show where they make Penne arrabbiata");
    item3.setExtraValue("duration", "127");
    item3.setCardImageUrl("http://www.gstatic.com/webp/gallery/5.jpg");
    item3.setUrl("http://html5demos.com/assets/dizzy.mp4");
    item3.setExtraValue("categories", new ArrayList<>(Collections.singletonList("International Cuisine")));
    item3.setExtraValue("channelId", 6341);
    // Add the items to the ContentBrowser root container
    ContentBrowser.getInstance(getActivity()).getRootContentContainer().addContent(item1);
    ContentBrowser.getInstance(getActivity()).getRootContentContainer().addContent(item2);
    ContentBrowser.getInstance(getActivity()).getRootContentContainer().addContent(item3);
}
Also used : Content(com.amazon.android.model.content.Content)

Example 2 with Content

use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.

the class ContentSearchFragmentTest method testOnQueryTextChangeWithInput.

/**
 * This test method will act as an user and manually input a search term.
 */
@Test
public void testOnQueryTextChangeWithInput() throws Exception {
    // Delay check for a bit.
    solo.sleep(3000);
    // Check to make sure no items come up with a blank search item.
    assertTrue("There should not be any items in the row", getActivity().mFragment.getResultsAdapter().size() == 0);
    // Enter the search term "r".
    solo.sendKey(Solo.DOWN);
    solo.sendKey(Solo.LEFT);
    solo.sendKey(Solo.LEFT);
    solo.sendKey(Solo.LEFT);
    solo.sendKey(Solo.ENTER);
    // Delay check for a bit.
    solo.sleep(3000);
    // Create a list row to find its contents.
    ListRow mListRow = (ListRow) getActivity().mFragment.getResultsAdapter().get(0);
    // Check to make sure we are getting the expected 3 items.
    assertTrue("There should be 3 items", mListRow.getAdapter().size() == 3);
    // Enter the rest of the search term "abbi".
    solo.sendKey(Solo.RIGHT);
    solo.sendKey(Solo.RIGHT);
    solo.sendKey(Solo.RIGHT);
    solo.sendKey(Solo.UP);
    solo.sendKey(Solo.ENTER);
    solo.sendKey(Solo.RIGHT);
    solo.sendKey(Solo.ENTER);
    solo.sendKey(Solo.ENTER);
    solo.sendKey(Solo.LEFT);
    solo.sendKey(Solo.LEFT);
    solo.sendKey(Solo.LEFT);
    solo.sendKey(Solo.ENTER);
    // Close the search soft keyboard.
    solo.sendKey(Solo.DOWN);
    solo.sendKey(Solo.DOWN);
    solo.sendKey(Solo.DOWN);
    solo.sendKey(Solo.DOWN);
    solo.sendKey(Solo.ENTER);
    // Update for the new list row.
    mListRow = (ListRow) getActivity().mFragment.getResultsAdapter().get(0);
    // Check that we are getting only one item back.
    assertTrue("There should only be one item", mListRow.getAdapter().size() == 1);
    // Verify we are getting the right movie.
    Content foundContent = (Content) mListRow.getAdapter().get(0);
    // Test that we have the right movie in the row.
    assertTrue("Title does not match", foundContent.getTitle().equals("Penne arrabbiata"));
}
Also used : Content(com.amazon.android.model.content.Content) ListRow(androidx.leanback.widget.ListRow) Test(org.junit.Test)

Example 3 with Content

use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.

the class RecommendationSenderTest method testGetContentFromRoot.

/**
 * Test getting a content from the sender's root.
 */
@Test
public void testGetContentFromRoot() throws Exception {
    Content content = mSender.getContentFromRoot("1");
    assertNotNull("Content should not be null", content);
    assertEquals("Content id should be 1", "1", content.getId());
}
Also used : Content(com.amazon.android.model.content.Content) Test(org.junit.Test)

Example 4 with Content

use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.

the class RecommendationSenderTest method testBuildRecommendation.

/**
 * Test building a recommendation.
 */
@Test
public void testBuildRecommendation() throws Exception {
    // A content with a bad genre set.
    Content content = createNewContent("10");
    content.setExtraValue(Content.GENRES_TAG, "bad genre input");
    mRoot.addContent(content);
    // A content with incorrect content types set.
    Content content2 = createNewContent("11");
    content2.setExtraValue(Content.CONTENT_TYPE_TAG, "not; a good type, 3");
    mRoot.addContent(content2);
    // A content with incorrect actions set.
    Content content3 = createNewContent("12");
    content3.setExtraValue(Content.RECOMMENDATION_ACTIONS_TAG, "noninteger");
    mRoot.addContent(content3);
    // A content with incorrect fire tv categories set.
    Content content4 = createNewContent("13");
    content4.setExtraValue(Content.FIRE_TV_CATEGORIES_TAG, 102);
    mRoot.addContent(content4);
    RecommendationSender sender = new RecommendationSender(InstrumentationRegistry.getTargetContext(), mRoot, false);
    Notification notification = sender.buildRecommendation("1", 1, RecommendationRecord.GLOBAL);
    assertEquals("Notification should have Global group type.", RecommendationRecord.GLOBAL, notification.getGroup());
    Bundle extras = notification.extras;
    assertEquals("The content id should be set in the extras map.", "1", extras.getString(RecommendationExtras.EXTRA_AMAZON_CONTENT_ID));
    testBadInputForRecommendation(sender, "10", 10);
    testBadInputForRecommendation(sender, "11", 11);
    testBadInputForRecommendation(sender, "12", 12);
    testBadInputForRecommendation(sender, "13", 13);
}
Also used : Content(com.amazon.android.model.content.Content) Bundle(android.os.Bundle) Notification(android.app.Notification) Test(org.junit.Test)

Example 5 with Content

use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.

the class FunctionalTest method init.

/**
 * Set up environment for testing.
 */
private void init() {
    // wait for browse screen to load
    solo.waitForView(R.id.full_content_browse_fragment, 0, TestConfig.LONG_TIMEOUT);
    // get item count
    count = 0;
    mContentContainer = ContentBrowser.getInstance(mSplashActivity).getRootContentContainer();
    List<Content> contentFound = new ArrayList<>();
    for (Content c : mContentContainer) {
        if (!contentFound.contains(c)) {
            contentFound.add(c);
            count++;
        }
    }
    // check if we are using sample feed
    Content firstItem = contentFound.get(0);
    boolean hasSampleVideo = firstItem.getTitle().contains("Sample item");
    boolean isValidSize = false;
    for (int s : SAMPLE_SIZES) {
        if (count == s) {
            isValidSize = true;
            break;
        }
    }
    isSampleFeed = hasSampleVideo && isValidSize;
    Log.i(TAG, "Feed loaded, number of distinct items = " + count);
    if (!isSampleFeed) {
        Log.w(TAG, "You do not appear to be using a sample feed. Testing on live feed " + "is disabled.");
    } else {
        Log.i(TAG, "Using sample feed with " + count + " items");
    }
}
Also used : Content(com.amazon.android.model.content.Content) ArrayList(java.util.ArrayList)

Aggregations

Content (com.amazon.android.model.content.Content)76 ContentContainer (com.amazon.android.model.content.ContentContainer)28 Test (org.junit.Test)26 ArrayObjectAdapter (androidx.leanback.widget.ArrayObjectAdapter)13 ListRow (androidx.leanback.widget.ListRow)13 ArrayList (java.util.ArrayList)11 Recipe (com.amazon.android.recipe.Recipe)10 Intent (android.content.Intent)8 RecentDatabaseHelper (com.amazon.android.contentbrowser.database.helpers.RecentDatabaseHelper)7 TextUtils (android.text.TextUtils)6 RecentRecord (com.amazon.android.contentbrowser.database.records.RecentRecord)6 CardPresenter (com.amazon.android.tv.tenfoot.presenter.CardPresenter)6 List (java.util.List)6 Context (android.content.Context)5 HeaderItem (androidx.leanback.widget.HeaderItem)5 Action (com.amazon.android.model.Action)5 NavigatorModel (com.amazon.android.navigator.NavigatorModel)5 AndroidSchedulers (rx.android.schedulers.AndroidSchedulers)5 Bundle (android.os.Bundle)4 Log (android.util.Log)4