forked from Tencent/Shadow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
201 additions
and
79 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
...droidTest/java/com/tencent/shadow/test/cases/plugin_main/PluginBroadcastReceiverTest.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,67 @@ | ||
package com.tencent.shadow.test.cases.plugin_main; | ||
|
||
import android.content.Intent; | ||
|
||
import androidx.test.core.app.ApplicationProvider; | ||
import androidx.test.espresso.Espresso; | ||
import androidx.test.espresso.action.ViewActions; | ||
import androidx.test.espresso.matcher.ViewMatchers; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.junit.Test; | ||
|
||
/** | ||
* 广播测试 | ||
*/ | ||
public class PluginBroadcastReceiverTest extends PluginMainAppTest { | ||
|
||
private final static String INTENT_NORMAL_ACTION = "com.tencent.test.normal.action"; | ||
private final static String INTENT_DYNAMIC_ACTION = "com.tencent.test.action.DYNAMIC"; | ||
|
||
private final static String MSG_NORMAL = "收到测试静态广播发送"; | ||
private final static String MSG_DYNAMIC = "收到动态动态广播发送"; | ||
|
||
|
||
@Override | ||
protected Intent getLaunchIntent() { | ||
Intent pluginIntent = new Intent(); | ||
String packageName = ApplicationProvider.getApplicationContext().getPackageName(); | ||
pluginIntent.setClassName( | ||
packageName, | ||
"com.tencent.shadow.test.plugin.general_cases.lib.usecases.receiver.TestReceiverActivity" | ||
); | ||
return pluginIntent; | ||
} | ||
|
||
/** | ||
* 动态广播测试 | ||
*/ | ||
@Test | ||
public void testDynamicBroadcastReceiver(){ | ||
//测试动态广播可以正常收到,并且action,extra,以及context都是正确的 | ||
Espresso.onView(ViewMatchers.withTagValue(Matchers.<Object>is("button_dynamic"))). | ||
perform(ViewActions.click()); | ||
matchTextWithViewTag("text", | ||
String.format("action:%s msg:%s isShadowContext:%s",INTENT_DYNAMIC_ACTION, | ||
MSG_DYNAMIC,"true")); | ||
|
||
//测试动态广播反注册后就收不到广播了 | ||
Espresso.onView(ViewMatchers.withTagValue(Matchers.<Object>is("button_unRegister_dynamic"))). | ||
perform(ViewActions.click()); | ||
matchTextWithViewTag("text", ""); | ||
|
||
} | ||
/** | ||
* 静态广播测试 | ||
*/ | ||
@Test | ||
public void testStaticBroadcastReceiver(){ | ||
//测试静态广播可以正常收到,并且action,extra,以及context都是正确的 | ||
Espresso.onView(ViewMatchers.withTagValue(Matchers.<Object>is("button_static"))). | ||
perform(ViewActions.click()); | ||
|
||
matchTextWithViewTag("text", | ||
String.format("action:%s msg:%s isShadowContext:%s",INTENT_NORMAL_ACTION, | ||
MSG_NORMAL,"true")); | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
...a/com/tencent/shadow/test/plugin/general_cases/lib/usecases/receiver/BroadCastHelper.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,25 @@ | ||
package com.tencent.shadow.test.plugin.general_cases.lib.usecases.receiver; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
|
||
public class BroadCastHelper { | ||
|
||
|
||
private static Notify notify; | ||
|
||
|
||
public static void setNotify(Notify notify) { | ||
BroadCastHelper.notify = notify; | ||
} | ||
|
||
public static void notify(Intent intent, Context context) { | ||
notify.onReceiver(intent, context); | ||
} | ||
|
||
interface Notify { | ||
void onReceiver(Intent intent, Context context); | ||
} | ||
|
||
|
||
} |
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
66 changes: 0 additions & 66 deletions
66
...t/shadow/test/plugin/general_cases/lib/usecases/receiver/TestDynamicReceiverActivity.java
This file was deleted.
Oops, something went wrong.
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