This repository has been archived by the owner on Apr 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[usecase-embeddingapi] Add tests for setJavaScript related APIs (#3731)
Impacted tests(approved): new 4, update 0, delete 0 Unit test platform: Crosswalk for Android 21.51.546.0 Unit test result summary: pass 4, fail 0, block 0 BUG=https://crosswalk-project.org/jira/browse/CTS-1818
- Loading branch information
Showing
25 changed files
with
629 additions
and
3 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
8 changes: 8 additions & 0 deletions
8
usecase/usecase-embedding-android-tests/embeddingapi-async/assets/javascript_enabled.html
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,8 @@ | ||
<html> | ||
<body> | ||
JavaScript Enabled: <span id="result">False</span> | ||
<script> | ||
document.getElementById("result").innerHTML = "True"; | ||
</script> | ||
</body> | ||
</html> |
12 changes: 12 additions & 0 deletions
12
.../usecase-embedding-android-tests/embeddingapi-async/assets/window_open_automatically.html
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,12 @@ | ||
<html> | ||
<body> | ||
Windows Open Automatically: <span id="result">Disabled</span> | ||
<script> | ||
try { | ||
window.open("window_open_automatically_enabled.html", "_blank", "") | ||
}catch(e) { | ||
logDiv.innerHTML = e; | ||
} | ||
</script> | ||
</body> | ||
</html> |
5 changes: 5 additions & 0 deletions
5
...-embedding-android-tests/embeddingapi-async/assets/window_open_automatically_enabled.html
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,5 @@ | ||
<html> | ||
<body> | ||
Windows Open Automatically: <span id="result">Enabled</span> | ||
</body> | ||
</html> |
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
36 changes: 36 additions & 0 deletions
36
...ts/embeddingapi-async/res/layout/activity_xwalk_view_setting_javascript_enabled_async.xml
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,36 @@ | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" | ||
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
tools:context="org.xwalk.embedded.api.sample.setting.XWalkViewSettingJavaScriptEnabledAsync"> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="Check that XWalkView can enable/disable JavaScript execution. Click the button to enable/disable JavaScript." | ||
android:id="@+id/textView" /> | ||
|
||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/message_tv" | ||
android:textColor="#00ff00" | ||
android:layout_below="@+id/textView"/> | ||
|
||
<Button | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/switch_al" | ||
android:layout_below="@+id/message_tv" | ||
android:layout_alignParentStart="true" /> | ||
|
||
<org.xwalk.core.XWalkView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:id="@+id/xwalk_view" | ||
android:layout_below="@+id/switch_al" /> | ||
|
||
</RelativeLayout> |
36 changes: 36 additions & 0 deletions
36
...nc/res/layout/activity_xwalk_view_setting_javascript_open_windows_automatically_async.xml
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,36 @@ | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" | ||
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
tools:context="org.xwalk.embedded.api.sample.setting.XWalkViewSettingJavaScriptCanOpenWindowsAutomaticallyAsync"> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="Check that XWalkView can enable/disable JavaScript open windows automatically. Click the button to enable/disable JavaScriptCanOpenWindowsAutomatically." | ||
android:id="@+id/textView" /> | ||
|
||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/message_tv" | ||
android:textColor="#00ff00" | ||
android:layout_below="@+id/textView"/> | ||
|
||
<Button | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/switch_al" | ||
android:layout_below="@+id/message_tv" | ||
android:layout_alignParentStart="true" /> | ||
|
||
<org.xwalk.core.XWalkView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:id="@+id/xwalk_view" | ||
android:layout_below="@+id/switch_al" /> | ||
|
||
</RelativeLayout> |
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
95 changes: 95 additions & 0 deletions
95
...d/api/asyncsample/setting/XWalkViewSettingJavaScriptCanOpenWindowsAutomaticallyAsync.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,95 @@ | ||
package org.xwalk.embedded.api.asyncsample.setting; | ||
|
||
import org.xwalk.core.XWalkInitializer; | ||
import org.xwalk.core.XWalkSettings; | ||
import org.xwalk.core.XWalkView; | ||
import org.xwalk.embedded.api.asyncsample.R; | ||
|
||
import android.app.Activity; | ||
import android.app.AlertDialog; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
|
||
public class XWalkViewSettingJavaScriptCanOpenWindowsAutomaticallyAsync extends Activity implements XWalkInitializer.XWalkInitListener { | ||
|
||
private XWalkInitializer mXWalkInitializer; | ||
|
||
public final static String ENABLE_BT = "Enable JavaScriptCanOpenWindowsAutomatically"; | ||
public final static String DISABLE_BT = "Disable JavaScriptCanOpenWindowsAutomatically"; | ||
public final static String MESSAGE_TITLE = "JavaScriptCanOpenWindowsAutomatically Enabled: "; | ||
|
||
private XWalkView mXWalkView; | ||
private TextView mMessage; | ||
private Button mButton; | ||
private XWalkSettings settings; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
mXWalkInitializer = new XWalkInitializer(this, this); | ||
mXWalkInitializer.initAsync(); | ||
} | ||
|
||
@Override | ||
public void onXWalkInitCancelled() { | ||
// TODO Auto-generated method stub | ||
} | ||
|
||
@Override | ||
public void onXWalkInitFailed() { | ||
// TODO Auto-generated method stub | ||
} | ||
|
||
@Override | ||
public void onXWalkInitStarted() { | ||
// TODO Auto-generated method stub | ||
} | ||
|
||
@Override | ||
public void onXWalkInitCompleted() { | ||
setContentView(R.layout.activity_xwalk_view_setting_javascript_open_windows_automatically_async); | ||
|
||
StringBuffer mess = new StringBuffer(); | ||
mess.append("Test Purpose: \n\n") | ||
.append("Check that XWalkView can enable/disable JavaScript open windows automatically.\n\n") | ||
.append("Expected Result:\n\n") | ||
.append("Test passes if XWalkView can enable/disable JavaScript open windows automatically during window.open()."); | ||
new AlertDialog.Builder(this) | ||
.setTitle("Info") | ||
.setMessage(mess.toString()) | ||
.setPositiveButton("confirm", null) | ||
.show(); | ||
|
||
mXWalkView = (XWalkView) findViewById(R.id.xwalk_view); | ||
mMessage = (TextView) findViewById(R.id.message_tv); | ||
mButton = (Button) findViewById(R.id.switch_al); | ||
settings = mXWalkView.getSettings(); | ||
boolean defaultValue = settings.getJavaScriptCanOpenWindowsAutomatically(); | ||
if (defaultValue) { | ||
mButton.setText(DISABLE_BT); | ||
}else{ | ||
mButton.setText(ENABLE_BT); | ||
} | ||
mMessage.setText(MESSAGE_TITLE + defaultValue + "(Default)"); | ||
mXWalkView.load("file:///android_asset/window_open_automatically.html", null); | ||
|
||
mButton.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
if (ENABLE_BT.equals(mButton.getText())) { | ||
settings.setJavaScriptCanOpenWindowsAutomatically(true); | ||
mButton.setText(DISABLE_BT); | ||
} else { | ||
settings.setJavaScriptCanOpenWindowsAutomatically(false); | ||
mButton.setText(ENABLE_BT); | ||
} | ||
mMessage.setText(MESSAGE_TITLE + settings.getJavaScriptCanOpenWindowsAutomatically()); | ||
mXWalkView.load("file:///android_asset/window_open_automatically.html", null); | ||
|
||
} | ||
}); | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
...rc/org/xwalk/embedded/api/asyncsample/setting/XWalkViewSettingJavaScriptEnabledAsync.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,95 @@ | ||
package org.xwalk.embedded.api.asyncsample.setting; | ||
|
||
import org.xwalk.core.XWalkInitializer; | ||
import org.xwalk.core.XWalkSettings; | ||
import org.xwalk.core.XWalkView; | ||
import org.xwalk.embedded.api.asyncsample.R; | ||
|
||
import android.app.Activity; | ||
import android.app.AlertDialog; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
|
||
public class XWalkViewSettingJavaScriptEnabledAsync extends Activity implements XWalkInitializer.XWalkInitListener { | ||
|
||
private XWalkInitializer mXWalkInitializer; | ||
|
||
public final static String ENABLE_BT = "Enable JavaScript"; | ||
public final static String DISABLE_BT = "Disable JavaScript"; | ||
public final static String MESSAGE_TITLE = "JavaScript Enabled: "; | ||
|
||
private XWalkView mXWalkView; | ||
private TextView mMessage; | ||
private Button mButton; | ||
private XWalkSettings settings; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
mXWalkInitializer = new XWalkInitializer(this, this); | ||
mXWalkInitializer.initAsync(); | ||
} | ||
|
||
@Override | ||
public void onXWalkInitCancelled() { | ||
// TODO Auto-generated method stub | ||
} | ||
|
||
@Override | ||
public void onXWalkInitFailed() { | ||
// TODO Auto-generated method stub | ||
} | ||
|
||
@Override | ||
public void onXWalkInitStarted() { | ||
// TODO Auto-generated method stub | ||
} | ||
|
||
@Override | ||
public void onXWalkInitCompleted() { | ||
setContentView(R.layout.activity_xwalk_view_setting_javascript_enabled_async); | ||
|
||
StringBuffer mess = new StringBuffer(); | ||
mess.append("Test Purpose: \n\n") | ||
.append("Check that XWalkView can enable/disable JavaScript execution.\n\n") | ||
.append("Expected Result:\n\n") | ||
.append("Test passes if JavaScript can be enabled/disabled"); | ||
new AlertDialog.Builder(this) | ||
.setTitle("Info") | ||
.setMessage(mess.toString()) | ||
.setPositiveButton("confirm", null) | ||
.show(); | ||
|
||
mXWalkView = (XWalkView) findViewById(R.id.xwalk_view); | ||
mMessage = (TextView) findViewById(R.id.message_tv); | ||
mButton = (Button) findViewById(R.id.switch_al); | ||
settings = mXWalkView.getSettings(); | ||
boolean defaultValue = settings.getJavaScriptEnabled(); | ||
if (defaultValue) { | ||
mButton.setText(DISABLE_BT); | ||
}else{ | ||
mButton.setText(ENABLE_BT); | ||
} | ||
mMessage.setText(MESSAGE_TITLE + defaultValue + "(Default)"); | ||
mXWalkView.load("file:///android_asset/javascript_enabled.html", null); | ||
|
||
mButton.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
if (ENABLE_BT.equals(mButton.getText())) { | ||
settings.setJavaScriptEnabled(true); | ||
mButton.setText(DISABLE_BT); | ||
} else { | ||
settings.setJavaScriptEnabled(false); | ||
mButton.setText(ENABLE_BT); | ||
} | ||
mMessage.setText(MESSAGE_TITLE + settings.getJavaScriptEnabled()); | ||
mXWalkView.load("file:///android_asset/javascript_enabled.html", null); | ||
|
||
} | ||
}); | ||
} | ||
} |
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.