Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Not able to pick an image from gallery using espresso tool

Đang mở
#285 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
30/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
android, java
Lĩnh vực
mobile-dev, testing

Hướng nghiên cứu

Bắt đầu với _test_e_testComposeWithAttachments và tương tác attachment_button, sau đó so sánh matcher ACTION_PICK ожида vọng với các intent đã được ghi lại, cho thấy ACTION_GET_CONTENT. Theo dõi luồng activity từ ComposePageObject.clickComposeButton() và xác định test cần quan sát và phản hồi intent nào; hoàn tất khi tương tác dự kiến được ghi lại và assertion đạt.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

I tried all the methods which are present on the internet but nothing works. Can someone help me with it?

Here is a code:

@Rule
public IntentsTestRule mActivityRule = new IntentsTestRule<>(
HomeScreenActivity.class);

@Before
public void setUp() {

    Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    Resources resources = InstrumentationRegistry.getTargetContext().getResources();
    Uri fileUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + resources
            .getResourcePackageName(R.mipmap.ic_launcher) + '/' + resources.getResourceTypeName(
            R.mipmap.ic_launcher) + '/' + resources.getResourceEntryName(R.mipmap.ic_launcher));
    Intent resultData = new Intent();
    resultData.setData(fileUri);
    Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData);

}

@Test
public void _test_e_testComposeWithAttachments()
{
    ComposePageObject.clickComposeButton();
    Matcher<Intent> expectedIntent = allOf(hasAction(Intent.ACTION_PICK),
            hasData(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI));
    //Intents.init();
    intending(expectedIntent).respondWith(mActivityResult);
    onView(withId(R.id.attachment_button)).perform(click());
    intended(allOf(expectedIntent));
    Intents.release();

Getting this error every time:

junit.framework.AssertionFailedError: Wanted to match 1 intents. Actually matched 0 intents.

IntentMatcher: ((has action: is "android.intent.action.PICK" and has data: is content://media/external/images/media))

Matched intents:[]

Recorded intents:
-Intent { cmp=com.essential.mail/.ComposeActivity (has extras) } handling packages:[[com.essential.mail]], extras:[Bundle[{compose.account_id=2, compose.action_type=compose}]])
-Intent { act=android.intent.action.GET_CONTENT cat=[android.intent.category.OPENABLE] typ=/ } handling packages:[[com.android.documentsui, com.android.music, com.android.gallery3d]])
at junit.framework.Assert.fail(Assert.java:50)

Ngôn ngữ chính
Java
Star
9.3k
Fork
3.6k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của android/testing-samples

Tất cả issue của android/testing-samples

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.