sample/src/androidTest/java/com/urbanairship/sample/SampleTest.java
@Test
    public void testBannerInAppMessageV2() throws Exception {

        // Create the actions map
        Map<String, JsonValue> actions = new HashMap<>();
        actions.put("add_tags_action", JsonValue.wrap("clicked_banner"));

        // Create the banner in-app message
        BannerDisplayContent displayContent = BannerDisplayContent.newBuilder()
                                                                  .setHeading(TextInfo.newBuilder()
                                                                                      .setText("Banner heading is bold")
                                                                                      .addStyle(TextInfo.STYLE_BOLD)
                                                                                      .setColor(Color.BLUE)
                                                                                      .setDrawable(R.drawable.ic_menu_home)
                                                                                      .build())
                                                                  .setMedia(MediaInfo.newBuilder()
                                                                                     .setUrl("https://media.giphy.com/media/JYsWwF82EGnpC/giphy.gif")
                                                                                     .setType(MediaInfo.TYPE_IMAGE)
                                                                                     .setDescription("mustache man")
                                                                                     .build())
                                                                  .setBody(TextInfo.newBuilder()
                                                                                   .setText("Banner body text is so cool its italic")
                                                                                   .addStyle(TextInfo.STYLE_ITALIC)
                                                                                   .setColor(Color.GREEN)
                                                                                   .build())
                                                                  .setButtonLayout(DisplayContent.BUTTON_LAYOUT_JOINED)
                                                                  .addButton(ButtonInfo.newBuilder()
                                                                                       .setId("button-one")
                                                                                       .setBackgroundColor(Color.BLUE)
                                                                                       .setId("button id 1")
                                                                                       .setBorderRadius(10)
                                                                                       .setBorderColor(Color.MAGENTA)
                                                                                       .setLabel(TextInfo.newBuilder()
                                                                                                         .setText("Button One")
                                                                                                         .build())
                                                                                       .addAction("add_tags_action", JsonValue.wrap("button_one"))
                                                                                       .build())
                                                                  .addButton(ButtonInfo.newBuilder()
                                                                                       .setBackgroundColor(Color.GRAY)
                                                                                       .setBorderRadius(2)
                                                                                       .setId("button-two")
                                                                                       .setLabel(TextInfo.newBuilder()
                                                                                                         .setText("Button Two")
                                                                                                         .setAlignment(TextInfo.ALIGNMENT_RIGHT)
                                                                                                         .build())
                                                                                       .addAction("add_tags_action", JsonValue.wrap("button_two"))
                                                                                       .build())
                                                                  .setDuration(10, TimeUnit.SECONDS)
                                                                  .setDismissButtonColor(Color.RED)
                                                                  .setActions(actions)
                                                                  .build();

        // Schedule banner in-app message
        scheduleInAppMessageV2Banner(displayContent);

        // Wait for in-app message to be displayed
        Thread.sleep(TimeUnit.SECONDS.toMillis(1));

        clickAndVerifyTagAdded("Banner heading is bold", "clicked_banner");

        // Schedule banner in-app message
        scheduleInAppMessageV2Banner(displayContent);

        // Wait for in-app message to be displayed
        Thread.sleep(TimeUnit.SECONDS.toMillis(1));

        clickAndVerifyTagAdded("Button One", "button_one");

        // Schedule banner in-app message
        scheduleInAppMessageV2Banner(displayContent);

        // Wait for in-app message to be displayed
        Thread.sleep(TimeUnit.SECONDS.toMillis(1));

        clickAndVerifyTagAdded("Button Two", "button_two");
    }
/**
     * Test a banner in-app message V2 with media image and two buttons.
     */
Test a banner in-app message V2 with media image and two buttons.
Test a banner in - app message V2 with media image and two buttons .
@Test
    public void testBannerInAppMessageV2() throws Exception {
        Map<String, JsonValue> actions = new HashMap<>();
        actions.put("add_tags_action", JsonValue.wrap("clicked_banner"));
        BannerDisplayContent displayContent = BannerDisplayContent.newBuilder()
                                                                  .setHeading(TextInfo.newBuilder()
                                                                                      .setText("Banner heading is bold")
                                                                                      .addStyle(TextInfo.STYLE_BOLD)
                                                                                      .setColor(Color.BLUE)
                                                                                      .setDrawable(R.drawable.ic_menu_home)
                                                                                      .build())
                                                                  .setMedia(MediaInfo.newBuilder()
                                                                                     .setUrl("https://media.giphy.com/media/JYsWwF82EGnpC/giphy.gif")
                                                                                     .setType(MediaInfo.TYPE_IMAGE)
                                                                                     .setDescription("mustache man")
                                                                                     .build())
                                                                  .setBody(TextInfo.newBuilder()
                                                                                   .setText("Banner body text is so cool its italic")
                                                                                   .addStyle(TextInfo.STYLE_ITALIC)
                                                                                   .setColor(Color.GREEN)
                                                                                   .build())
                                                                  .setButtonLayout(DisplayContent.BUTTON_LAYOUT_JOINED)
                                                                  .addButton(ButtonInfo.newBuilder()
                                                                                       .setId("button-one")
                                                                                       .setBackgroundColor(Color.BLUE)
                                                                                       .setId("button id 1")
                                                                                       .setBorderRadius(10)
                                                                                       .setBorderColor(Color.MAGENTA)
                                                                                       .setLabel(TextInfo.newBuilder()
                                                                                                         .setText("Button One")
                                                                                                         .build())
                                                                                       .addAction("add_tags_action", JsonValue.wrap("button_one"))
                                                                                       .build())
                                                                  .addButton(ButtonInfo.newBuilder()
                                                                                       .setBackgroundColor(Color.GRAY)
                                                                                       .setBorderRadius(2)
                                                                                       .setId("button-two")
                                                                                       .setLabel(TextInfo.newBuilder()
                                                                                                         .setText("Button Two")
                                                                                                         .setAlignment(TextInfo.ALIGNMENT_RIGHT)
                                                                                                         .build())
                                                                                       .addAction("add_tags_action", JsonValue.wrap("button_two"))
                                                                                       .build())
                                                                  .setDuration(10, TimeUnit.SECONDS)
                                                                  .setDismissButtonColor(Color.RED)
                                                                  .setActions(actions)
                                                                  .build();
        scheduleInAppMessageV2Banner(displayContent);
        Thread.sleep(TimeUnit.SECONDS.toMillis(1));
        clickAndVerifyTagAdded("Banner heading is bold", "clicked_banner");
        scheduleInAppMessageV2Banner(displayContent);
        Thread.sleep(TimeUnit.SECONDS.toMillis(1));
        clickAndVerifyTagAdded("Button One", "button_one");
        scheduleInAppMessageV2Banner(displayContent);
        Thread.sleep(TimeUnit.SECONDS.toMillis(1));
        clickAndVerifyTagAdded("Button Two", "button_two");
    }
@ Test public void testBannerInAppMessageV2 ( ) throws Exception { Map < String , JsonValue > actions = new HashMap < > ( ) ; actions . put ( "add_tags_action" , JsonValue . wrap ( "clicked_banner" ) ) ; BannerDisplayContent displayContent = BannerDisplayContent . newBuilder ( ) . setHeading ( TextInfo . newBuilder ( ) . setText ( "Banner heading is bold" ) . addStyle ( TextInfo . STYLE_BOLD ) . setColor ( Color . BLUE ) . setDrawable ( R . drawable . ic_menu_home ) . build ( ) ) . setMedia ( MediaInfo . newBuilder ( ) . setUrl ( "https://media.giphy.com/media/JYsWwF82EGnpC/giphy.gif" ) . setType ( MediaInfo . TYPE_IMAGE ) . setDescription ( "mustache man" ) . build ( ) ) . setBody ( TextInfo . newBuilder ( ) . setText ( "Banner body text is so cool its italic" ) . addStyle ( TextInfo . STYLE_ITALIC ) . setColor ( Color . GREEN ) . build ( ) ) . setButtonLayout ( DisplayContent . BUTTON_LAYOUT_JOINED ) . addButton ( ButtonInfo . newBuilder ( ) . setId ( "button-one" ) . setBackgroundColor ( Color . BLUE ) . setId ( "button id 1" ) . setBorderRadius ( 10 ) . setBorderColor ( Color . MAGENTA ) . setLabel ( TextInfo . newBuilder ( ) . setText ( "Button One" ) . build ( ) ) . addAction ( "add_tags_action" , JsonValue . wrap ( "button_one" ) ) . build ( ) ) . addButton ( ButtonInfo . newBuilder ( ) . setBackgroundColor ( Color . GRAY ) . setBorderRadius ( 2 ) . setId ( "button-two" ) . setLabel ( TextInfo . newBuilder ( ) . setText ( "Button Two" ) . setAlignment ( TextInfo . ALIGNMENT_RIGHT ) . build ( ) ) . addAction ( "add_tags_action" , JsonValue . wrap ( "button_two" ) ) . build ( ) ) . setDuration ( 10 , TimeUnit . SECONDS ) . setDismissButtonColor ( Color . RED ) . setActions ( actions ) . build ( ) ; scheduleInAppMessageV2Banner ( displayContent ) ; Thread . sleep ( TimeUnit . SECONDS . toMillis ( 1 ) ) ; clickAndVerifyTagAdded ( "Banner heading is bold" , "clicked_banner" ) ; scheduleInAppMessageV2Banner ( displayContent ) ; Thread . sleep ( TimeUnit . SECONDS . toMillis ( 1 ) ) ; clickAndVerifyTagAdded ( "Button One" , "button_one" ) ; scheduleInAppMessageV2Banner ( displayContent ) ; Thread . sleep ( TimeUnit . SECONDS . toMillis ( 1 ) ) ; clickAndVerifyTagAdded ( "Button Two" , "button_two" ) ; }
Test a banner in-app message V2 with media image and two buttons.
Test a banner in - app message V2 with media image and two buttons .
// Create the actions map // Create the banner in-app message // Schedule banner in-app message // Wait for in-app message to be displayed // Schedule banner in-app message // Wait for in-app message to be displayed // Schedule banner in-app message // Wait for in-app message to be displayed