27 Mart 2025'ten itibaren AOSP'yi derlemek ve AOSP'ye katkıda bulunmak için aosp-main
yerine android-latest-release
kullanmanızı öneririz. Daha fazla bilgi için AOSP'de yapılan değişiklikler başlıklı makaleyi inceleyin.
GoogleTest
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Platform için GoogleTest (GTest, bazen "yerel testler" olarak da adlandırılır), genellikle alt düzey HAL'lere erişir veya çeşitli sistem hizmetlerine karşı ham IPC gerçekleştirir. Bu nedenle, test yaklaşımı genellikle test edilen hizmetle sıkı bir şekilde bağlanır.
Sürekli test altyapısıyla entegrasyon için GTest çerçevesini kullanarak GTest'lerinizi oluşturun.
Örnekler
Platform kaynağındaki GTest örneklerini aşağıda bulabilirsiniz:
Adımların özeti
Örnek GTest modülü kurulumunu uygulayın.
GTest bağımlılıkları otomatik olarak dahil etmek için test modülü yapılandırmanızda BUILD_NATIVE_TEST
derleme kuralını kullanın.
Basit ve karmaşık seçeneklerle ilgili örnekleri izleyerek bir test yapılandırması yazın.
Artımlı derlemeler için mmm
, tam derlemeler için mma
ile test modülü oluşturun:
make hwui_unit_tests -j
Atest'i kullanarak testi yerel olarak çalıştırın:
atest hwui_unit_tests
GTests'inize bağımsız değişkenler de ekleyebilirsiniz. Aşağıdakiler özellikle yararlı bağımsız değişkenlerdir:
native-test-flag
, GTest kabuk komutuna iletilecek ek işaret değerlerini belirtir.
native-test-timeout
, mikrosaniye cinsinden bir test zaman aşımı değeri belirtir.
Aşağıdaki örnek kodda bu iki bağımsız değişkenin her ikisi de kullanılmaktadır:
atest test-name -- --module-arg test-name:native-test-flag:"\"argument1 argument2\"" \
--module-arg test-name:native-test-timeout:60000
Testi Trade Federation test aparatıyla çalıştırın:
make tradefed-all -j
tradefed.sh run template/local_min --template:map test=hwui_unit_tests
Aşağıdakileri manuel olarak yükleyip çalıştırın:
Oluşturulan test ikilisini cihazınıza aktarın:
adb push ${OUT}/data/nativetest/hwui_unit_tests/hwui_unit_tests \
/data/nativetest/hwui_unit_tests/hwui_unit_tests
GTest'i başlatın ve cihazda test ikilisini çağırarak testi yürütün:
adb shell /data/nativetest/hwui_unit_tests/hwui_unit_tests
Test yürütmeyi özelleştirme hakkında daha fazla bilgi için test ikilinize --help
parametresini ekleyin. Parametreler hakkında daha fazla bilgi için GTest gelişmiş kılavuzuna bakın.
Bu sayfadaki içerik ve kod örnekleri, İçerik Lisansı sayfasında açıklanan lisanslara tabidir. Java ve OpenJDK, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-07-27 UTC.
[[["Anlaması kolay","easyToUnderstand","thumb-up"],["Sorunumu çözdü","solvedMyProblem","thumb-up"],["Diğer","otherUp","thumb-up"]],[["İhtiyacım olan bilgiler yok","missingTheInformationINeed","thumb-down"],["Çok karmaşık / çok fazla adım var","tooComplicatedTooManySteps","thumb-down"],["Güncel değil","outOfDate","thumb-down"],["Çeviri sorunu","translationIssue","thumb-down"],["Örnek veya kod sorunu","samplesCodeIssue","thumb-down"],["Diğer","otherDown","thumb-down"]],["Son güncelleme tarihi: 2025-07-27 UTC."],[],[],null,["# GoogleTest\n\nA GoogleTest (GTest, also sometimes called \"native tests\") for the platform\ntypically accesses lower-level HALs or performs raw IPC against various system\nservices. Because of this, the testing approach is usually tightly coupled with\nthe service under test.\n\nTo integrate with continuous testing infrastructure, build your GTests\nusing the [GTest](https://github.com/google/googletest)\nframework.\n\nExamples\n--------\n\nHere are some examples of GTest in the platform source:\n\n- [frameworks/av/camera/tests](https://android.googlesource.com/platform/frameworks/av/+/android16-release/camera/tests/)\n- [frameworks/native/libs/gui/tests](https://android.googlesource.com/platform/frameworks/native/+/android16-release/libs/gui/tests/)\n\nSummary of steps\n----------------\n\n1. Follow the [example GTest module setup](https://android.googlesource.com/platform/frameworks/base/+/android16-release/libs/hwui/tests/unit/).\n\n2. To automatically include GTest dependencies, use the `BUILD_NATIVE_TEST`\n build rule in your test module configuration.\n\n3. Write a test configuration, following the examples for [simple](/docs/core/tests/development/blueprints)\n and [complex](/docs/core/tests/development/test-config) options.\n\n4. Build the test module with `mmm` for incremental builds, or `mma` for full\n builds:\n\n make hwui_unit_tests -j\n\n5. Run the test locally using [Atest](/docs/core/tests/development/atest):\n\n atest hwui_unit_tests\n\n You can also add arguments to your GTests. The following are especially useful arguments:\n - `native-test-flag` specifies additional flag values to pass to the GTest shell command.\n - `native-test-timeout` specifies a test timeout value in microseconds.\n\n The following example code uses both of these arguments: \n\n atest test-name -- --module-arg test-name:native-test-flag:\"\\\"argument1 argument2\\\"\" \\\n --module-arg test-name:native-test-timeout:60000\n\n6. Run the test with the Trade Federation test harness:\n\n make tradefed-all -j\n tradefed.sh run template/local_min --template:map test=hwui_unit_tests\n\n7. Manually install and run:\n\n 1. Push the generated test binary onto your device:\n\n adb push ${OUT}/data/nativetest/hwui_unit_tests/hwui_unit_tests \\\n /data/nativetest/hwui_unit_tests/hwui_unit_tests\n\n 2. Launch GTest and execute the test by invoking the test binary on the device:\n\n adb shell /data/nativetest/hwui_unit_tests/hwui_unit_tests\n\n For more information about customizing test execution, add the `--help`\n parameter to your test binary. For more information on parameters, refer to\n the [GTest advanced guide](https://github.com/google/googletest/blob/master/googletest/docs/advanced.md)."]]