-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from apptentive/branch_5.1.0
Release 5.1.0
- Loading branch information
Showing
153 changed files
with
4,233 additions
and
1,848 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
apptentive/src/androidTest/java/com/apptentive/android/sdk/InstrumentationTestCaseBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) 2018, Apptentive, Inc. All Rights Reserved. | ||
* Please refer to the LICENSE file for the terms and conditions | ||
* under which redistribution and use of this file is permitted. | ||
*/ | ||
|
||
package com.apptentive.android.sdk; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.test.RenamingDelegatingContext; | ||
|
||
public class InstrumentationTestCaseBase extends TestCaseBase { | ||
protected Context getContext() { | ||
return new RenamingDelegatingContext(InstrumentationRegistry.getTargetContext(), "test_"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...ndroidTest/java/com/apptentive/android/sdk/module/engagement/InteractionLauncherTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright (c) 2016, Apptentive, Inc. All Rights Reserved. | ||
* Please refer to the LICENSE file for the terms and conditions | ||
* under which redistribution and use of this file is permitted. | ||
*/ | ||
|
||
package com.apptentive.android.sdk.module.engagement; | ||
|
||
import android.content.Context; | ||
import android.support.annotation.NonNull; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import com.apptentive.android.sdk.InstrumentationTestCaseBase; | ||
import com.apptentive.android.sdk.module.engagement.interaction.model.Interaction; | ||
import com.apptentive.android.sdk.module.engagement.interaction.model.Interaction.DisplayType; | ||
import com.apptentive.android.sdk.module.engagement.interaction.model.TextModalInteraction; | ||
import com.apptentive.android.sdk.util.RuntimeUtils; | ||
|
||
import org.json.JSONException; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static junit.framework.Assert.assertEquals; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class InteractionLauncherTest extends InstrumentationTestCaseBase { | ||
|
||
@Before | ||
@Override | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
|
||
RuntimeUtils.overrideStaticFinalField(EngagementModule.class, "LAUNCHER_FACTORY", new DefaultInteractionLauncherFactory() { | ||
@NonNull | ||
@Override | ||
protected InteractionLauncher createActivityInteractionLauncher() { | ||
return new MockInteractionLauncher("Activity"); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
protected InteractionLauncher createNotificationInteractionLauncher() { | ||
return new MockInteractionLauncher("Notification"); | ||
} | ||
}); | ||
|
||
// Everything should run immediately | ||
overrideMainQueue(true); | ||
} | ||
|
||
@Test | ||
public void testInteractionDefaultDisplayType() throws JSONException { | ||
Interaction interaction = new TextModalInteraction("{\"type\":\"TextModal\"}"); | ||
assertEquals(interaction.getDisplayType(), DisplayType.unknown); | ||
EngagementModule.launchInteraction(getContext(), interaction); | ||
assertResult("Activity"); | ||
} | ||
|
||
@Test | ||
public void testInteractionNotificationDisplayType() throws JSONException { | ||
Interaction interaction = new TextModalInteraction("{\"type\":\"TextModal\",\"display_type\":\"notification\"}"); | ||
assertEquals(interaction.getDisplayType(), DisplayType.notification); | ||
EngagementModule.launchInteraction(getContext(), interaction); | ||
assertResult("Notification"); | ||
} | ||
|
||
@Test | ||
public void testInteractionUnknownDisplayType() throws JSONException { | ||
Interaction interaction = new TextModalInteraction("{\"type\":\"TextModal\",\"display_Type\":\"unknown\"}"); | ||
assertEquals(interaction.getDisplayType(), DisplayType.unknown); | ||
EngagementModule.launchInteraction(getContext(), interaction); | ||
assertResult("Activity"); | ||
} | ||
|
||
class MockInteractionLauncher implements InteractionLauncher { | ||
private final String name; | ||
|
||
MockInteractionLauncher(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public boolean launch(Context context, Interaction interaction) { | ||
addResult(name); | ||
return true; | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...ve/android/sdk/module/engagement/InteractionNotificationBroadcastReceiverHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2016, Apptentive, Inc. All Rights Reserved. | ||
* Please refer to the LICENSE file for the terms and conditions | ||
* under which redistribution and use of this file is permitted. | ||
*/ | ||
|
||
package com.apptentive.android.sdk.module.engagement; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import com.apptentive.android.sdk.InstrumentationTestCaseBase; | ||
import com.apptentive.android.sdk.module.engagement.interaction.model.Interaction; | ||
import com.apptentive.android.sdk.module.engagement.interaction.model.TextModalInteraction; | ||
import com.apptentive.android.sdk.module.engagement.notification.ApptentiveNotificationInteractionBroadcastReceiver; | ||
import com.apptentive.android.sdk.module.engagement.notification.DefaultInteractionNotificationBroadcastReceiverHandler; | ||
import com.apptentive.android.sdk.util.Constants; | ||
import com.apptentive.android.sdk.util.RuntimeUtils; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static junit.framework.Assert.assertEquals; | ||
import static junit.framework.Assert.assertNotNull; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class InteractionNotificationBroadcastReceiverHandlerTest extends InstrumentationTestCaseBase { | ||
|
||
@Test | ||
public void testNoteNotification() throws Exception { | ||
final String interactionDefinition = "{\"type\":\"TextModal\",\"name\":\"TextModal Interaction displayed as Notification\",\"id\":\"textmodal_interaction_notification\",\"displayType\":\"Notification\",\"priority\":1,\"configuration\":{\"title\":\"Note Title\",\"body\":\"Note body\",\"actions\":[{\"id\":\"action_id_1\",\"label\":\"Dismiss\",\"action\":\"dismiss\"},{\"id\":\"action_id_2\",\"label\":\"Dismiss\",\"action\":\"dismiss\"}]}}"; | ||
Interaction interaction = new TextModalInteraction(interactionDefinition); | ||
|
||
RuntimeUtils.overrideStaticFinalField(ApptentiveNotificationInteractionBroadcastReceiver.class, "DEFAULT_HANDLER", new DefaultInteractionNotificationBroadcastReceiverHandler() { | ||
@Override | ||
public void handleBroadcast(Context context, Intent intent) { | ||
assertNotNull(intent); | ||
assertEquals(Constants.NOTIFICATION_ACTION_DISPLAY, intent.getAction()); | ||
assertEquals(interactionDefinition, intent.getStringExtra(Constants.NOTIFICATION_EXTRA_INTERACTION_DEFINITION)); | ||
} | ||
}); | ||
EngagementModule.launchInteraction(getContext(), interaction); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
.../com/apptentive/android/sdk/module/engagement/NoteInteractionNotificationAdapterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2016, Apptentive, Inc. All Rights Reserved. | ||
* Please refer to the LICENSE file for the terms and conditions | ||
* under which redistribution and use of this file is permitted. | ||
*/ | ||
|
||
package com.apptentive.android.sdk.module.engagement; | ||
|
||
import android.content.Context; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import com.apptentive.android.sdk.InstrumentationTestCaseBase; | ||
import com.apptentive.android.sdk.module.engagement.interaction.model.Interaction; | ||
import com.apptentive.android.sdk.module.engagement.interaction.model.TextModalInteraction; | ||
import com.apptentive.android.sdk.module.engagement.notification.DefaultInteractionNotificationBroadcastReceiverHandler; | ||
import com.apptentive.android.sdk.module.engagement.notification.NoteInteractionNotificationAdapter; | ||
import com.apptentive.android.sdk.util.RuntimeUtils; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static com.apptentive.android.sdk.util.Constants.NOTIFICATION_CHANNEL_DEFAULT; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class NoteInteractionNotificationAdapterTest extends InstrumentationTestCaseBase { | ||
|
||
@Test | ||
public void testNoteNotificationDisplay() throws Exception { | ||
final String interactionDefinition = "{\"type\":\"TextModal\",\"name\":\"TextModal Interaction displayed as Notification\",\"id\":\"textmodal_interaction_notification\",\"display_type\":\"notification\",\"priority\":1,\"configuration\":{\"title\":\"Note Title\",\"body\":\"Note body\",\"actions\":[{\"id\":\"action_id_1\",\"label\":\"Dismiss\",\"action\":\"dismiss\"},{\"id\":\"action_id_2\",\"label\":\"Dismiss\",\"action\":\"dismiss\"}]}}"; | ||
Interaction interaction = new TextModalInteraction(interactionDefinition); | ||
|
||
RuntimeUtils.overrideStaticFinalField(DefaultInteractionNotificationBroadcastReceiverHandler.class, "DEFAULT_ADAPTER_NOTE", new NoteInteractionNotificationAdapter() { | ||
@Override | ||
protected void actionDisplayNotification(Context context, String channelId, TextModalInteraction interaction) { | ||
assertNotNull(context); | ||
assertEquals(NOTIFICATION_CHANNEL_DEFAULT, channelId); | ||
assertNotNull(interaction); | ||
assertEquals(Interaction.Type.TextModal, interaction.getType()); | ||
assertEquals("Note Title", interaction.getTitle()); | ||
assertEquals("Note body", interaction.getBody()); | ||
} | ||
}); | ||
EngagementModule.launchInteraction(getContext(), interaction); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.