提交 72944093 编写于 作者: 杜庆泉's avatar 杜庆泉

补充string.match 测试示例

上级 753011c8
...@@ -200,6 +200,25 @@ class RootActivityStartListener extends OnClickListener{ ...@@ -200,6 +200,25 @@ class RootActivityStartListener extends OnClickListener{
} }
} }
class RootPageStartListener extends OnClickListener{
host:Activity
constructor(activity:Activity){
super()
this.host = activity
}
override onClick(v?: View):void{
let packageName = UTSAndroid.getAppContext()!.getPackageName()
console.log("packageName",packageName)
console.log("host",this.host)
let intent = host.getPackageManager().getLaunchIntentForPackage(packageName)
intent?.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
host.startActivity(intent)
}
}
/** /**
* 自定义异步线程 * 自定义异步线程
*/ */
...@@ -281,6 +300,9 @@ class DemoActivity extends Activity{ ...@@ -281,6 +300,9 @@ class DemoActivity extends Activity{
let btn_start_root_activity = this.findViewById<Button>(R.id.btn_start_root_activity); let btn_start_root_activity = this.findViewById<Button>(R.id.btn_start_root_activity);
btn_start_root_activity.setOnClickListener(new RootActivityStartListener(this)); btn_start_root_activity.setOnClickListener(new RootActivityStartListener(this));
let btn_start_root_page = this.findViewById<Button>(R.id.btn_start_root_page);
btn_start_root_page.setOnClickListener(new RootPageStartListener(this));
let recyclerView = this.findViewById<RecyclerView>(R.id.recycler_view) let recyclerView = this.findViewById<RecyclerView>(R.id.recycler_view)
let layoutManager = new LinearLayoutManager(this); let layoutManager = new LinearLayoutManager(this);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="开启异步任务" android:id="@+id/btn_start_thread"/> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="开启异步任务" android:id="@+id/btn_start_thread"/>
<Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="关闭当前activity" android:id="@+id/btn_finish_activity"/> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="关闭当前activity" android:id="@+id/btn_finish_activity"/>
<Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="打开应用根目录activity" android:id="@+id/btn_start_root_activity"/> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="打开应用根目录activity" android:id="@+id/btn_start_root_activity"/>
<Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="打开应用首页" android:id="@+id/btn_start_root_page"/>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
......
...@@ -136,6 +136,13 @@ export function testString(): Result { ...@@ -136,6 +136,13 @@ export function testString(): Result {
expect(result4!![0]).toEqual("rgb(255, 0, 0)"); expect(result4!![0]).toEqual("rgb(255, 0, 0)");
expect(result4!![1]).toEqual("255"); expect(result4!![1]).toEqual("255");
expect(result4!![2]).toEqual("0"); expect(result4!![2]).toEqual("0");
const url = '';
const urlRegex = /^(\w+):\/\/([^\/?#]+)([^?#]*)(\?[^#]*)?(#.*)?$/;
const match = url.match(urlRegex);
expect(match).toEqual(null);
}) })
test('padEnd', () => { test('padEnd', () => {
const str1 = 'Breaded Mushrooms'; const str1 = 'Breaded Mushrooms';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册