-
Notifications
You must be signed in to change notification settings - Fork 16
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
15 changed files
with
290 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Check | ||
on: workflow_call | ||
|
||
jobs: | ||
check-format: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Java™ Setup | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v4 | ||
- name: Check Code Format | ||
run: ./gradlew checkFormat | ||
|
||
check-jni: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Java™ Setup | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
- name: Check JNI | ||
run: | | ||
cd tools/jni-test && \ | ||
cmake -S. -Bbuild && \ | ||
cmake --build build --target run |
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 @@ | ||
name: Lint | ||
on: | ||
workflow_call: | ||
inputs: | ||
build_type: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
lint-checks: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Fetch Dependencies (WPE Bootstrap) | ||
run: python3 tools/scripts/bootstrap.py -a all | ||
- name: Java™ Setup | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v4 | ||
- name: Lint checks | ||
run: ./gradlew lint${{ inputs.build_type }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Test | ||
on: workflow_call | ||
|
||
env: | ||
apiLevel: '33' | ||
arch: 'x86_64' | ||
|
||
jobs: | ||
instrumentation-tests: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Java™ Setup | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
- name: Fetch Dependencies (WPE Bootstrap) | ||
run: python3 tools/scripts/bootstrap.py -a x86_64 | ||
- name: Remmove layouttests and webdrivertests | ||
run: | | ||
rm -rf layouttests | ||
rm -rf webdrivertests | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v4 | ||
- name: Enable KVM | ||
run: | | ||
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | ||
sudo udevadm control --reload-rules | ||
sudo udevadm trigger --name-match=kvm | ||
- name: AVD cache | ||
uses: actions/cache@v4 | ||
id: avd-cache | ||
with: | ||
path: | | ||
~/.android/avd/* | ||
~/.android/adb* | ||
key: avd-${{ env.apiLevel }} | ||
- name: Create AVD and generate snapshot for caching | ||
if: steps.avd-cache.outputs.cache-hit != 'true' | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
api-level: ${{ env.apiLevel }} | ||
arch: ${{ env.arch }} | ||
force-avd-creation: false | ||
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | ||
disable-animations: false | ||
script: echo "Generated AVD snapshot for caching." | ||
- name: Instrumented Tests | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
api-level: ${{ env.apiLevel }} | ||
arch: ${{ env.arch }} | ||
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | ||
script: ./gradlew wpe:connectedDebugAndroidTest |
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
94 changes: 94 additions & 0 deletions
94
wpe/src/androidTest/java/com/wpe/wpeview/WPEViewImeTest.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,94 @@ | ||
package com.wpe.wpeview; | ||
|
||
import android.content.Context; | ||
import android.graphics.Insets; | ||
import android.util.Log; | ||
import android.view.WindowInsets; | ||
import android.view.inputmethod.InputMethodManager; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.lifecycle.Lifecycle; | ||
import androidx.test.core.app.ActivityScenario; | ||
import androidx.test.ext.junit.rules.ActivityScenarioRule; | ||
import androidx.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class WPEViewImeTest { | ||
@Rule | ||
public ActivityScenarioRule<WPEViewTestActivity> wpeViewActivityTestRule = | ||
new ActivityScenarioRule<>(WPEViewTestActivity.class); | ||
@Test | ||
public void testIMEVisible() { | ||
CountDownLatch latch = new CountDownLatch(1); | ||
ActivityScenario<WPEViewTestActivity> scenario = wpeViewActivityTestRule.getScenario(); | ||
scenario.onActivity(activity -> { | ||
activity.getWPEView().setWPEViewClient(new WPEViewClient() { | ||
@Override | ||
public void onPageFinished(@NonNull WPEView view, @NonNull String url) { | ||
String focusScript = "function onDocumentFocused() {\n" | ||
+ " document.getElementById('editor').focus();\n" | ||
+ " test.onEditorFocused();\n" | ||
+ "}\n" | ||
+ "(function() {\n" | ||
+ "if (document.hasFocus()) {\n" | ||
+ " onDocumentFocused();" | ||
+ "} else {\n" | ||
+ " window.addEventListener('focus', onDocumentFocused);\n" | ||
+ "}})();"; | ||
view.evaluateJavascript(focusScript, new WPECallback<String>() { | ||
@Override | ||
public void onResult(String value) { | ||
latch.countDown(); | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
String htmlDocument = "<html><body contenteditable id='editor'></body></html>"; | ||
activity.getWPEView().loadHtml(htmlDocument, null); | ||
}); | ||
|
||
scenario.moveToState(Lifecycle.State.RESUMED); | ||
|
||
try { | ||
latch.await(10, TimeUnit.SECONDS); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
try { | ||
// Give IME time to popup | ||
Thread.sleep(10000); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
CountDownLatch secondLatch = new CountDownLatch(1); | ||
|
||
AtomicBoolean keyboardShown = new AtomicBoolean(false); | ||
scenario.onActivity(activity -> { | ||
keyboardShown.set(activity.getWPEView().getRootWindowInsets().isVisible(WindowInsets.Type.ime())); | ||
|
||
secondLatch.countDown(); | ||
}); | ||
|
||
try { | ||
secondLatch.await(10, TimeUnit.SECONDS); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
assertTrue(keyboardShown.get()); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
wpe/src/androidTest/java/com/wpe/wpeview/WPEViewTestActivity.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,30 @@ | ||
package com.wpe.wpeview; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.widget.LinearLayout; | ||
|
||
public class WPEViewTestActivity extends Activity { | ||
|
||
private WPEView wpeView; | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
LinearLayout linearLayout = new LinearLayout(this); | ||
linearLayout.setOrientation(LinearLayout.VERTICAL); | ||
linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, | ||
LinearLayout.LayoutParams.MATCH_PARENT)); | ||
|
||
wpeView = new WPEView(getApplicationContext()); | ||
wpeView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, | ||
LinearLayout.LayoutParams.MATCH_PARENT, 1f)); | ||
linearLayout.addView(wpeView); | ||
|
||
setContentView(linearLayout); | ||
} | ||
|
||
public WPEView getWPEView() { return wpeView; } | ||
} |
Oops, something went wrong.