From 7de877a191c675bb5c423fe36c846816fd6d0869 Mon Sep 17 00:00:00 2001 From: Littlegnal <8847263+littleGnAl@users.noreply.github.com> Date: Mon, 27 May 2024 17:56:10 +0800 Subject: [PATCH] [test_shard] Fix some tests failed after upgrading the Flutter SDK 3.22 (#1777) Some tests failed after upgrading the Flutter SDK 3.22, see https://github.com/AgoraIO-Extensions/Agora-Flutter-SDK/actions/runs/9177683376/job/25235867951?pr=1774 - Remove the use of `Theme.of(context).textTheme.headline4`. - We previously added the `iris_web_version.js` as assets, and let the Flutter SDK copy the `iris_web_version.js` to the web folder, which does not work on Windows with Flutter SDK 3.22. We now copy the `iris_web_version.js` before running the test explicitly. - The method channel call of `destroyTextureRender ` does not be mocked - Remove the `FakeMethodChannelController.dispose`, which may reset the mock `MethodChannelCallHandler` too early, which caused an error on Windows(We checked the texture id can not be 0 on Windows). --- .gitignore | 3 +- ci/run_flutter_integration_test.sh | 10 ++++- ci/run_rendering_test.sh | 10 ++++- test_shard/fake_test_app/lib/main.dart | 3 +- test_shard/fake_test_app/pubspec.yaml | 4 +- test_shard/fake_test_app/web/index.html | 2 +- .../fake_agora_video_view_testcases.dart | 39 ++++++++----------- .../lib/fake_remote_user_main.dart | 3 +- test_shard/integration_test_app/lib/main.dart | 3 +- test_shard/rendering_test/lib/main.dart | 3 +- test_shard/rendering_test/pubspec.yaml | 2 - test_shard/rendering_test/web/index.html | 2 +- 12 files changed, 41 insertions(+), 43 deletions(-) diff --git a/.gitignore b/.gitignore index ad892843b..7b90fe538 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,5 @@ third_party/ .ccls-cache/ -test_shard/**/scripts/iris_web_version.js \ No newline at end of file +test_shard/**/scripts/iris_web_version.js +test_shard/**/web/iris_web_version.js \ No newline at end of file diff --git a/ci/run_flutter_integration_test.sh b/ci/run_flutter_integration_test.sh index f935d10ff..3fdb587ee 100644 --- a/ci/run_flutter_integration_test.sh +++ b/ci/run_flutter_integration_test.sh @@ -3,13 +3,19 @@ set -e set -x -MY_PATH=$(dirname "$0") +MY_PATH=$(realpath $(dirname "$0")) +PROJECT_ROOT=$(realpath ${MY_PATH}/..) PLATFORM=$1 # android/ios/macos/windows/web if [[ ${PLATFORM} == "web" ]];then - pushd ${MY_PATH}/../test_shard/fake_test_app + pushd ${PROJECT_ROOT}/test_shard/fake_test_app + + IRIS_WEB_VERSION_PATH=${PROJECT_ROOT}/scripts/iris_web_version.js + rm -rf web/iris_web_version.js + cp -RP ${IRIS_WEB_VERSION_PATH} web/ echo "Run integration test on web" + echo "If you want to run integration test on your local machine, please follow the https://docs.flutter.dev/testing/integration-tests#test-in-a-web-browser to setup first." flutter packages get diff --git a/ci/run_rendering_test.sh b/ci/run_rendering_test.sh index 99272439b..070eef71c 100644 --- a/ci/run_rendering_test.sh +++ b/ci/run_rendering_test.sh @@ -3,14 +3,20 @@ set -e set -x -MY_PATH=$(dirname "$0") +MY_PATH=$(realpath $(dirname "$0")) +PROJECT_ROOT=$(realpath ${MY_PATH}/..) PLATFORM=$1 # android/ios/macos/windows/web -pushd ${MY_PATH}/../test_shard/rendering_test +pushd ${PROJECT_ROOT}/test_shard/rendering_test flutter packages get if [[ ${PLATFORM} == "web" ]];then + + IRIS_WEB_VERSION_PATH=${PROJECT_ROOT}/scripts/iris_web_version.js + rm -rf web/iris_web_version.js + cp -RP ${IRIS_WEB_VERSION_PATH} web/ + echo "Run rendering test on web" flutter drive \ diff --git a/test_shard/fake_test_app/lib/main.dart b/test_shard/fake_test_app/lib/main.dart index 07ab34bc8..48d84c326 100644 --- a/test_shard/fake_test_app/lib/main.dart +++ b/test_shard/fake_test_app/lib/main.dart @@ -139,8 +139,7 @@ class _MyHomePageState extends State { 'You have pushed the button this many times:', ), Text( - '$_counter', - style: Theme.of(context).textTheme.headline4, + '$_counter' ), ], ), diff --git a/test_shard/fake_test_app/pubspec.yaml b/test_shard/fake_test_app/pubspec.yaml index c7c4b1665..f44187520 100644 --- a/test_shard/fake_test_app/pubspec.yaml +++ b/test_shard/fake_test_app/pubspec.yaml @@ -69,9 +69,7 @@ flutter: uses-material-design: true # To add assets to your application, add an assets section, like this: - assets: - # Add the `../../scripts/iris_web_version.js` to the assets, so we can use it in the `web/index.html` file. - - ../../scripts/iris_web_version.js + # assets: # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see diff --git a/test_shard/fake_test_app/web/index.html b/test_shard/fake_test_app/web/index.html index 60d5404d7..72da0c4fe 100644 --- a/test_shard/fake_test_app/web/index.html +++ b/test_shard/fake_test_app/web/index.html @@ -43,7 +43,7 @@ - + +