Flutter Web Test: Set the window size for chrome using flutter drive for integration test - flutter

So I have a project, with some integration testing for flutter web. I want to run these tests inside GitHub Actions. For that, I need to change the window size of chrome while testing, as in the default dimensions, some widgets are overflowing, therefore, getting out of the screen, making them non-interactable. I want to run the browser in 1920x1080 resolution. Currently, I am using the following steps to run it:
chromedriver --port=4444 &
sudo /usr/bin/Xvfb -ac $DISPLAY -screen 0 1920x1080x24 > /dev/null 2>&1 & # optional
I have already updated the resolution from xvfb, but it did nothing. I also tried adding the following code in the test file itself.
const size = Size(1920, 1080);
await tester.binding.setSurfaceSize(size);
tester.binding.window.physicalSizeTestValue = size;
But these also did not update the screen size.
For running the tests I am using flutter drive command, like this:
flutter drive --driver=test_driver/integration_test.dart --target=integration_test/test.dart -d chrome --web-renderer=html --headless

Related

How to fix the sdk_addon data copy build error?

I tried to build the Android SDK Addon System Image of halogenOS 13 (AOSP 13, nothing was changed in the AOSP source code yet).
The steps to build are as usual:
source build/envsetup.sh
lunch aosp_sdk_phone_x86_64-eng
m sdk_addon
At 100%, the build fails with following error:
[100% 12483/12483] Packaging SDK Addon System-Image: out/host/linux-x86/sdk_addon/custom-eng.simao--
FAILED: out/host/linux-x86/sdk_addon/custom-eng.simao--img.zip
/bin/bash -c "(cp -R out/target/product/emulator_x86_64/data out/host/linux-x86/obj/SDK_ADDON/custom_intermediates/custom-eng.simao--img/images/x86_64/data ) && (out/host/linux-x86/bin/soong_zip -o out/host/linux-x86/sdk_addon/custom-eng.simao--img.zip -C out/host/linux-x86/obj/SDK_ADDON/custom_intermediates/custom-eng.simao--img/images/ -D out/host/linux-x86/obj/SDK_ADDON/custom_intermediates/custom-eng.simao--img/images/x86_64 )"
cp: bad 'out/target/product/emulator_x86_64/data': No such file or directory
13:17:13 ninja failed with: exit status 1
If I just mkdir out/target/product/emulator_x86_64/data, of course, that just solves the build error but the SDK addon does not actually boot in the emulator due to encryption issues with the userdata partition so I think this is related. This makes me guess that in the data directory there should be some files in there but for some reason the are not created.
EDIT:
What's really odd here is that the file device/generic/goldfish/vendor.mk explicitly adds some data files to PRODUCT_COPY_FILES, notably:
PRODUCT_COPY_FILES += \
device/generic/goldfish/data/etc/dtb.img:dtb.img \
device/generic/goldfish/emulator-info.txt:data/misc/emulator/version.txt \
device/generic/goldfish/data/etc/apns-conf.xml:data/misc/apns/apns-conf.xml \
device/generic/goldfish/radio/RadioConfig/radioconfig.xml:data/misc/emulator/config/radioconfig.xml \
device/generic/goldfish/data/etc/iccprofile_for_sim0.xml:data/misc/modem_simulator/iccprofile_for_sim0.xml \
If I manually build them using, for example, m out/target/product/emulator_x86_64/data/misc/emulator/version.txt, the file is created at the correct location, as expected. Which leads me to wonder when entries PRODUCT_COPY_FILES are considered targets to be built and when they aren't.
EDIT2:
I got the emulator to boot but the data directory is still not being created. (Creating manually or building one target in the data dir is a workaorund).

Flutter commands stuck waiting for startup lock

I'm using macOS Catalina v10.15.5, and just installed flutter using git. But whenever I execute flutter commands (flutter doctor, flutter precache), I'm stuck at Waiting for another flutter command to release the startup lock...
Has been leaving it for >30min, still stuck at the error page.
List of solutions I've tried:
killall -9 dart -> gets "No matching processes belonging to you were found FAIL: 1"
Removing <YOUR FLUTTER FOLDER>/bin/cache/lockfile -> there is no lockfile
delete the directory & restart PC & download again -> still the same error message
Try remove flock check in _lock function in bin/internal/shared.sh like this
function _lock () {
if hash shlock 2>/dev/null; then
shlock -f "$1" -p $$
else
mkdir "$1" 2>/dev/null
fi
}
For my case, my mac system had a flock enabled, but it was failing to acquire the lock.
Try creating a new flutter project via File > Create new flutter project.
This will remove the lock.

QProcess not accepting arguments in MacOS

Running Qt5.10 on MacOS 10.13.2
I am trying to open photoshop with one or more selected images in MacOS. In terminal this works:
open "/Users/roryhill/Pictures/4K/2017-01-25_0030-Edit.jpg" -a "Adobe Photoshop CS6"
The following works in Windows but not MacOS:
QString app = "\"/Applications/Adobe Photoshop CS6/Adobe Photoshop CS6.app\""; // diff file path for windows
QStringList arguments;
arguments << "/Users/roryhill/Pictures/4K/2017-01-25_0030-Edit.jpg";
QProcess *process = new QProcess();
process->start(app, arguments);
In MacOS I get the error: "FailedToStart".
If I drop the arguments in the last line and use:
process->start(app);
then photoshop opens.
I have also tried using the executable inside the app container:
"/Applications/Adobe Photoshop CS6/Adobe Photoshop CS6.app/Contents/MacOS/Adobe Photoshop CS6"
Again this works to open photoshop but fails when arguments are added.
This also fails:
process->setArguments(arguments);
process->setProgram(app);
process->start();
Omitting setArguments() fails too:
process->setProgram(app);
process->start();

How to mount sd card to android source-built emulator?

I've built the android source code and run the emulator successfully except one thing - SD card couldn't be mounted. Here is how I tried to mount it.
1. create a sdcard.img by mksdcard tool under /out/host/linux-x86/bin/
mksdcard 256M out/target/product/generic/sdcard.img
sdcard.img is rw
run emulator with command line:
out/host/linux-x86/bin/emulator -sysdir out/target/product/generic/ -system out/target/product/generic/system.img -ramdisk out/target/product/generic/ramdisk.img -data out/target/product/generic/userdata.img -kernel prebuilt/android-arm/kernel/kernel-qemu -skindir sdk/emulator/skins -skin WVGA800 -scale 0.7 -memory 512 -partition-size 2024 -sdcard out/target/product/generic/sdcard.img
the file under /system/etc/vold.conf is ok.
system log shows:
<6>mmc0: new SD card at address e118
<6>mmcblk0: mmc0:e118 SU02G 256 MiB
<6> mmcblk0:
But the truth is that it failed to mount sdcard. It will get a "read only" error if trying to write data in /mnt/sdcard/
Anyone can help on this? thanks in advance.
just follow below step:
Goto the Android Virtual device manager
click New for create new Vitual device
Add Name and choose your package
Under hardware you just click New Button and then pop new Window
After select SdCard support in drop down list near Property
finally you have gotten emulator with SDCard support
First, emulator should work without any parameters by setting up the right environment variables as described here.
Create sd card image file sdcard.img (on linux, using dd /dev/zero to make empty file filled by zeroes suffices)
Make FAT or ext4 filesystem on it (on linux, mkdosfs path/to/sdcard.img) It should be possible to skip this step and format it from within emulator, too.
Then run
emulator -sdcard path/to/sdcard.img
In my case, it shows in Settings as "usb storage", instead of "sd card".

Running JUnit-Tests that uses SWT-Display fails on Jenkins

I a have a few JUnit-Tests that makes use of the current Display to instantiate a few controls (TreeViewer for instance). Locally that works fine, no problem. When I commit these tests and jenkins runs the test I get a failed test for each test that makes use of Display.
My unit test uses the display variable in this manner:
#Test
public void testUtils() {
Display display = Display.getCurrent();
Shell shell = new Shell(display, SWT.NONE);
// org.eclipse.swt.widgets.Composite composite = new
// org.eclipse.swt.widgets.Composite(
// shell, SWT.NONE);
TreeViewer viewer = new TreeViewer(shell, SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL);
The error log jenkins generates is:
Time elapsed: 0.13 sec <<< ERROR!
org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
at org.eclipse.swt.SWT.error(SWT.java:4109)
at org.eclipse.swt.widgets.Display.createDisplay(Display.java:902)
at org.eclipse.swt.widgets.Display.create(Display.java:890)
at org.eclipse.swt.graphics.Device.<init>(Device.java:154)
at org.eclipse.swt.widgets.Display.<init>(Display.java:499)
at org.eclipse.swt.widgets.Display.<init>(Display.java:490)
at org.eclipse.swt.widgets.Display.getDefault(Display.java:1693)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:260)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:253)
at
Is there any thing wrong with the way I am using Display in my tests? It works when executed on my local machine
The way you use Display looks OK to me. The error is likely related to the fact that your server is not running Gnome, hence SWT can't create a Display when you ask it to.
UPDATE
I just found a recent blog post, which explains what you need to do to run SWT UI tests on a headless server in more detail. Although the steps provided are meant for Hudson, they should be applicable to Jenkins as well.
It should all boil down to these two steps:
Check Run Xvnc during build (and don’t bother to check take screenshot, it doesn’t work)
Add an Execute shell build action before launching your tests with metacity –replace –sm-disable &
See the linked blog post for screenshots and more details.
You can try following two things,
execute command "xhost" or "xhost+" from your terminnal.
execute command "xhost" or "xhost+" from, jenkins terminal.