Merge pull request #9674 from nextcloud/fixUploadingFailingScreenshots

Fix failing username/password upon uploading failing screenshots
This commit is contained in:
Álvaro Brey 2022-01-10 11:30:26 +01:00 committed by GitHub
commit c9246210de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 10 deletions

View file

@ -35,11 +35,8 @@ jobs:
script: ./gradlew gplayDebugExecuteScreenshotTests -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest -Pandroid.testInstrumentationRunnerArguments.COLOR=${{ matrix.color }} -Pandroid.testInstrumentationRunnerArguments.DARKMODE=${{ matrix.scheme }} script: ./gradlew gplayDebugExecuteScreenshotTests -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest -Pandroid.testInstrumentationRunnerArguments.COLOR=${{ matrix.color }} -Pandroid.testInstrumentationRunnerArguments.DARKMODE=${{ matrix.scheme }}
- name: upload failing results - name: upload failing results
if: ${{ failure() }} if: ${{ failure() }}
env:
LOG_USERNAME: ${{ secrets.LOG_USERNAME }}
LOG_PASSWORD: ${{ secrets.LOG_PASSWORD }}
run: run:
scripts/uploadReport.sh "$LOG_USERNAME" "$LOG_PASSWORD" ${{github.event.number}} "${{ matrix.color }}-${{ matrix.scheme }}" "Screenshot" ${{github.event.number}} ${{ secrets.GITHUB_TOKEN }} scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "${{ matrix.color }}-${{ matrix.scheme }}" "Screenshot" ${{github.event.number}} ${{ secrets.GITHUB_TOKEN }}
- name: Archive Espresso results - name: Archive Espresso results
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
if: ${{ always() }} if: ${{ always() }}

View file

@ -80,10 +80,10 @@ else
-X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \ -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
-d "{ \"body\" : \"$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }" -d "{ \"body\" : \"$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }"
if [ -e build/reports/androidTests/connected/flavors/gplayDebugAndroidTest ] ; then if [ -e build/reports/androidTests/connected/flavors/gplay ] ; then
TYPE="IT" TYPE="IT"
BRANCH_TYPE=$BRANCH-$TYPE BRANCH_TYPE=$BRANCH-$TYPE
upload "build/reports/androidTests/connected/flavors/gplayDebugAndroidTest" upload "build/reports/androidTests/connected/flavors/gplay"
fi fi
if [ -e build/reports/tests/testGplayDebugUnitTest ] ; then if [ -e build/reports/tests/testGplayDebugUnitTest ] ; then

View file

@ -177,7 +177,8 @@ public class DialogFragmentIT extends AbstractIT {
@Test @Test
@ScreenshotTest @ScreenshotTest
public void testAccountChooserDialog() throws AccountUtils.AccountNotFoundException { public void testAccountChooserDialog() throws AccountUtils.AccountNotFoundException {
UserAccountManager userAccountManager = activityRule.getActivity().getUserAccountManager(); FileDisplayActivity activity = activityRule.launchActivity(null);
UserAccountManager userAccountManager = activity.getUserAccountManager();
AccountManager accountManager = AccountManager.get(targetContext); AccountManager accountManager = AccountManager.get(targetContext);
for (Account account : accountManager.getAccountsByType(MainApp.getAccountType(targetContext))) { for (Account account : accountManager.getAccountsByType(MainApp.getAccountType(targetContext))) {
accountManager.removeAccountExplicitly(account); accountManager.removeAccountExplicitly(account);
@ -210,7 +211,7 @@ public class DialogFragmentIT extends AbstractIT {
new OwnCloudAccount(newAccount, targetContext), new OwnCloudAccount(newAccount, targetContext),
new Server(URI.create(SERVER_URL), new Server(URI.create(SERVER_URL),
OwnCloudVersion.nextcloud_20))); OwnCloudVersion.nextcloud_20)));
FileDisplayActivity activity = showDialog(sut); activity = showDialog(sut);
activity.runOnUiThread(() -> sut.setStatus(new Status(StatusType.DND, activity.runOnUiThread(() -> sut.setStatus(new Status(StatusType.DND,
"Busy fixing 🐛…", "Busy fixing 🐛…",
@ -248,6 +249,7 @@ public class DialogFragmentIT extends AbstractIT {
@Test @Test
@ScreenshotTest @ScreenshotTest
public void testAccountChooserDialogWithStatusDisabled() throws AccountUtils.AccountNotFoundException { public void testAccountChooserDialogWithStatusDisabled() throws AccountUtils.AccountNotFoundException {
FileDisplayActivity activity = activityRule.launchActivity(null);
AccountManager accountManager = AccountManager.get(targetContext); AccountManager accountManager = AccountManager.get(targetContext);
for (Account account : accountManager.getAccounts()) { for (Account account : accountManager.getAccounts()) {
accountManager.removeAccountExplicitly(account); accountManager.removeAccountExplicitly(account);
@ -259,7 +261,7 @@ public class DialogFragmentIT extends AbstractIT {
accountManager.setUserData(newAccount, AccountUtils.Constants.KEY_USER_ID, "test"); accountManager.setUserData(newAccount, AccountUtils.Constants.KEY_USER_ID, "test");
accountManager.setAuthToken(newAccount, AccountTypeUtils.getAuthTokenTypePass(newAccount.type), "password"); accountManager.setAuthToken(newAccount, AccountTypeUtils.getAuthTokenTypePass(newAccount.type), "password");
UserAccountManager userAccountManager = activityRule.getActivity().getUserAccountManager(); UserAccountManager userAccountManager = activity.getUserAccountManager();
User newUser = userAccountManager.getUser(newAccount.name).get(); User newUser = userAccountManager.getUser(newAccount.name).get();
FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(newUser, FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(newUser,
targetContext.getContentResolver()); targetContext.getContentResolver());
@ -429,7 +431,12 @@ public class DialogFragmentIT extends AbstractIT {
private FileDisplayActivity showDialog(DialogFragment dialog) { private FileDisplayActivity showDialog(DialogFragment dialog) {
Intent intent = new Intent(targetContext, FileDisplayActivity.class); Intent intent = new Intent(targetContext, FileDisplayActivity.class);
FileDisplayActivity sut = activityRule.launchActivity(intent);
FileDisplayActivity sut = activityRule.getActivity();
if (sut == null) {
sut = activityRule.launchActivity(intent);
}
dialog.show(sut.getSupportFragmentManager(), ""); dialog.show(sut.getSupportFragmentManager(), "");