دلالات
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تستخدِم اختبارات واجهة المستخدم في Compose الدلالات للتفاعل مع هيكلية واجهة المستخدم.
تمنح الدلالات، كما يوحي الاسم، معنىً لجزء من واجهة المستخدم. في هذا السياق، يمكن أن تعني "جزءًا من واجهة المستخدم" (أو عنصرًا) أي شيء بدءًا من عنصر واحد قابل للإنشاء إلى شاشة كاملة. يتم إنشاء شجرة الدلالات إلى جانب التسلسل الهرمي لواجهة المستخدم، وهي تصف هذا التسلسل.
يمكنك الاطّلاع على مزيد من المعلومات حول الدلالات بشكل عام في الدلالات في Compose.
الشكل 1. هيكل نموذجي لواجهة المستخدم وشجرة الدلالات الخاصة به
يُستخدَم إطار عمل الدلالات بشكل أساسي لتسهيل الاستخدام، لذا تستفيد الاختبارات من المعلومات التي تعرضها الدلالات حول التسلسل الهرمي لواجهة المستخدم.
يحدّد المطوّرون البيانات التي سيتم عرضها ومقدارها.
الشكل 2. زر نموذجي يحتوي على رمز ونص
على سبيل المثال، إذا كان لديك زر يتضمّن رمزًا وعنصرًا نصيًا، لن تتضمّن شجرة الدلالات التلقائية سوى التصنيف النصي "أعجبني". ويرجع ذلك إلى أنّ بعض العناصر القابلة للإنشاء، مثل Text
، تعرض بعض الخصائص لشجرة الدلالات. يمكنك إضافة خصائص إلى شجرة الدلالات باستخدام Modifier
.
MyButton(
modifier = Modifier.semantics { contentDescription = "Add to favorites" }
)
مراجع إضافية
- اختبار التطبيقات على Android: تقدّم صفحة Android الرئيسية الخاصة بالاختبار نظرة عامة على أساسيات الاختبار وأساليبه.
- أساسيات الاختبار: مزيد من المعلومات
عن المفاهيم الأساسية لاختبار تطبيق Android
- الاختبارات المحلية: يمكنك إجراء بعض الاختبارات محليًا على محطة العمل الخاصة بك.
- الاختبارات المبرمَجة: من الممارسات الجيدة أيضًا إجراء اختبارات مبرمَجة. أي الاختبارات التي يتم إجراؤها مباشرةً على الجهاز.
- التكامل المستمر:
يتيح لك التكامل المستمر دمج اختباراتك في مسار النشر.
- اختبار أحجام الشاشات المختلفة: بما أنّ المستخدمين يتوفّر لديهم العديد من الأجهزة، عليك اختبار أحجام الشاشات المختلفة.
- Espresso: على الرغم من أنّ Espresso مخصّصة لواجهات المستخدم المستندة إلى العرض، يمكن أن تكون معرفة Espresso مفيدة في بعض جوانب اختبار Compose.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-08-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-08-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Semantics\n\nUI tests in Compose use *semantics* to interact with the UI hierarchy.\nSemantics, as the name implies, give meaning to a piece of UI. In this context,\na \"piece of UI\" (or element) can mean anything from a single composable to a\nfull screen. The *semantics tree* is generated alongside the UI hierarchy and\ndescribes the hierarchy.\n\nYou can learn more about semantics generally in [Semantics in Compose](/develop/ui/compose/accessibility/semantics).\n\n**Figure 1.** A typical UI hierarchy and its semantics tree.\n\nThe semantics framework is primarily used for accessibility, so tests take\nadvantage of the information exposed by semantics about the UI hierarchy.\nDevelopers decide what and how much to expose.\n\n**Figure 2.** A typical button containing an icon and text.\n\nFor example, given a button like this that consists of an icon and a text\nelement, the default semantics tree only contains the text label \"Like\". This is\nbecause some composables, such as `Text`, already expose some properties to the\nsemantics tree. You can add properties to the semantics tree by using a\n`Modifier`. \n\n MyButton(\n modifier = Modifier.semantics { contentDescription = \"Add to favorites\" }\n )\n\nAdditional Resources\n--------------------\n\n- **[Test apps on Android](/training/testing)**: The main Android testing landing page provides a broader view of testing fundamentals and techniques.\n- **[Fundamentals of testing](/training/testing/fundamentals):** Learn more about the core concepts behind testing an Android app.\n- **[Local tests](/training/testing/local-tests):** You can run some tests locally, on your own workstation.\n- **[Instrumented tests](/training/testing/instrumented-tests):** It is good practice to also run instrumented tests. That is, tests that run directly on-device.\n- **[Continuous integration](/training/testing/continuous-integration):** Continuous integration lets you integrate your tests into your deployment pipeline.\n- **[Test different screen sizes](/training/testing/different-screens):** With some many devices available to users, you should test for different screen sizes.\n- **[Espresso](/training/testing/espresso)**: While intended for View-based UIs, Espresso knowledge can still be helpful for some aspects of Compose testing."]]