thunderbird / thunderbird/thunderbird-android

Offer to Contribute Reproducible Test Case for Previously Reported Bug

Open
#9,211 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
14k
Forks
2.8k
Avg merge
3d 3h
Merged PRs (30d)
57

Description

Hello!

I saw that the app previously had a bug (issue #3971). I created a test (based on that version of the app) to help ensuring that the issue does not happen again. In other words, the test could be used for regression testing.

Would it be helpful if I contributed this test to your codebase? I’d be happy to open a pull request for the latest version, integrating the test with your existing test infrastructure.

Additionally, I’ve created similar regression tests for 8 other issues in the repository that I would also be happy to integrate if it would be helpful.

You can find the script for issue #3971 below:


import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;

import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;

import androidx.test.filters.SdkSuppress;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.UiObjectNotFoundException;
import androidx.test.uiautomator.UiSelector;
import androidx.test.uiautomator.Until;

import java.util.concurrent.TimeUnit;

import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

/**
 * Regression test for K-9 Mail (com.fsck.k9).
 * Verifies back navigation from the manual account setup screen does not leave the app in an invalid state.
 */
@RunWith(AndroidJUnit4.class)
@SdkSuppress(minSdkVersion = 18)
public class K9ManualSetupBackNavigationTest {

    private static final String BASIC_SAMPLE_PACKAGE = "com.fsck.k9";
    private static final String INSTALLER_PACKAGE = "com.android.packageinstaller";
    private static final int LAUNCH_TIMEOUT = 5000;

    private UiDevice mDevice;

    @Before
    public void startMainActivityFromHomeScreen() throws UiObjectNotFoundException {
        mDevice = UiDevice.getInstance(getInstrumentation());

        // Optional: dismiss initial system dialog if present
        UiObject2 gotIt = mDevice.wait(Until.findObject(By.text("GOT IT")), 2000);
        if (gotIt != null) {
            gotIt.click();
        }

        // Return to home screen
        mDevice.pressHome();

        // Wait for launcher
        final String launcherPackage = getLauncherPackageName();
        assertThat(launcherPackage, notNullValue());
        mDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), LAUNCH_TIMEOUT);

        // Launch the app
        Context context = getApplicationContext();
        Intent intent = context.getPackageManager()
                .getLaunchIntentForPackage(BASIC_SAMPLE_PACKAGE);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
        context.startActivity(intent);

        mDevice.wait(Until.hasObject(By.pkg(BASIC_SAMPLE_PACKAGE).depth(0)), LAUNCH_TIMEOUT);
    }

    @Test
    public void testChangeText_sameActivity() {
        // Navigate through initial account setup screen
        UiObject2 nextButton = mDevice.wait(Until.findObject(By.res(BASIC_SAMPLE_PACKAGE, "next")), 2000);
        nextButton.click();

        // Fill in dummy credentials
        UiObject2 emailField = mDevice.wait(Until.findObject(By.res(BASIC_SAMPLE_PACKAGE, "account_email")), 2000);
        emailField.setText("email@email.com");

        UiObject2 passwordField = mDevice.wait(Until.findObject(By.res(BASIC_SAMPLE_PACKAGE, "account_password")), 2000);
        passwordField.setText("password");

        // Click "Manual setup"
        UiObject2 manualSetupButton = mDevice.wait(Until.findObject(By.res(BASIC_SAMPLE_PACKAGE, "manual_setup")), 2000);
        manualSetupButton.click();

        // Press back twice to exit manual setup flow
        mDevice.pressBack();
        mDevice.pressBack();

        // === Oracle ===
        // After pressing back, we should be on the setup screen
        UiObject2 setupPrompt = mDevice.findObject(By.text("Set up a new account"));
        assertFalse("Expected setup screen to be dismissed after back presses", setupPrompt == null);
    }

    /**
     * Retrieves the device's launcher package name (compatible with various launchers).
     */
    private String getLauncherPackageName() {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        PackageManager pm = getApplicationContext().getPackageManager();
        ResolveInfo resolveInfo = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
        return resolveInfo.activityInfo.packageName;
    }
}

Please let me know if you're open to this or if there are any contribution guidelines I should follow.

Thanks for your work on this project!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the supplied K9ManualSetupBackNavigationTest for issue #3971 and checking the repository's current Android test infrastructure. Confirm whether the reproduced back-navigation behavior still applies, integrate the regression test for the current app, and verify the behavior with the existing test setup; the issue also proposes tests for eight other reports.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.