Docs: Changes to source.android.com - 225558908 Automated g4 rollback of changelist 225461674. by Android Partner Docs <[email protected]> - 225550864 Devsite localized content from translation request 1036674. by Android Partner Docs <[email protected]> - 225547899 Fix broken link by Danielle Roberts <[email protected]> - 225547403 Drop additional whitespace introduced by accident when tr... by Android Partner Docs <[email protected]> - 225536653 Add official guideline for headers for extended VNDK by Android Partner Docs <[email protected]> - 225489731 Devsite localized content from translation request 1015203. by Android Partner Docs <[email protected]> - 225489729 Devsite localized content from translation request 1047579. by Android Partner Docs <[email protected]> - 225489727 Devsite localized content from translation request 1047590. by Android Partner Docs <[email protected]> - 225465663 Fix typo by Android Partner Docs <[email protected]> - 225461674 Revert CID update by Danielle Roberts <[email protected]> - 225458889 Add setup/build/dashboard to devsite; Link from homepage ... by Android Partner Docs <[email protected]> - 225452187 Update catching exceptions per Tobias' CL http://ag/57916... by Christina Nguyen <[email protected]> - 225410221 Created a guide to access work profile contacts. by Android Partner Docs <[email protected]> - 225380106 Devsite localized content from translation request 1044541. by Android Partner Docs <[email protected]> - 225280142 Remove holdover 9.0 directory from zh-cn localized files. by Gina Dimino <[email protected]> - 225276176 Changing reviewer to gdimino by Gina Dimino <[email protected]> - 225268401 Add benefits of Atest to introductory statement by Android Partner Docs <[email protected]> - 225268205 Fix "directorys" typo in TEST MAPPING doc by Android Partner Docs <[email protected]> - 225261448 Clean up the HTML formatting so that the file is easier f... by Christina Nguyen <[email protected]> - 225251081 Secure Element: Fix typos for few test cases by Android Partner Docs <[email protected]> - 225206956 Update build numbers for 2018/12 Docomo releases by Android Partner Docs <[email protected]> - 225195616 Devsite localized content from translation request 1046264. by Android Partner Docs <[email protected]> - 225195419 Devsite localized content from translation request 1024866. by Android Partner Docs <[email protected]> - 225195391 Devsite localized content from translation request 1040016. by Android Partner Docs <[email protected]> - 225195374 Devsite localized content from translation request 1032282. by Android Partner Docs <[email protected]> - 225059126 Secure Element: Add clarification on test cases by Android Partner Docs <[email protected]> - 225018931 Devsite localized content from translation request 1045477. by Android Partner Docs <[email protected]> - 224904315 Devsite localized content from translation request 1044282. by Android Partner Docs <[email protected]> - 224904309 Devsite localized content from translation request 1029445. by Android Partner Docs <[email protected]> - 224904295 Devsite localized content from translation request 1044542. by Android Partner Docs <[email protected]> - 224897168 Removed the comment tag and "Comming soon" for the local... by Luke Haviland <[email protected]> - 224891868 Add Luke to localization configs by Danielle Roberts <[email protected]> - 224860068 Devsite localized content from translation request 1044262. by Android Partner Docs <[email protected]> - 224752674 Devsite localized content from translation request 1026891. by Android Partner Docs <[email protected]> - 224752671 Devsite localized content from translation request 1061530. by Android Partner Docs <[email protected]> - 224752667 Devsite localized content from translation request 1040025. by Android Partner Docs <[email protected]> - 224752636 Devsite localized content from translation request 1008389. by Android Partner Docs <[email protected]> - 224752634 Devsite localized content from translation request 1013269. by Android Partner Docs <[email protected]> - 224752628 Devsite localized content from translation request 1020396. by Android Partner Docs <[email protected]> - 224422875 Add link to Packaging Build Rules section anchor by Android Partner Docs <[email protected]> - 224421602 Move Atests links from AOSP to SAC, standardize envar setup by Android Partner Docs <[email protected]> - 224421460 Fix code example "MyLuiActivity" by Kenneth Lau <[email protected]> - 224420429 Fix incorrect starting path to all Atest links by Android Partner Docs <[email protected]> - 224417300 Replace AOSP link for Atest with native page by Android Partner Docs <[email protected]> - 224252988 Fix "Title Case" to "Sentence case" for H2 and lower. by Android Partner Docs <[email protected]> - 224233356 Fix broken link on APK Signing page by Kenneth Lau <[email protected]> - 224204432 Updated AOSP links by Luke Haviland <[email protected]> - 224200053 Added AOSP Links to December Bulletin. by Luke Haviland <[email protected]> - 224182129 Add Atest and Test Mapping to News section of home page by Android Partner Docs <[email protected]> - 224162840 Devsite localized content from translation request 1024730. by Android Partner Docs <[email protected]> - 224159473 Remove text regarding notification email group. by Android Partner Docs <[email protected]> - 224086085 Add terminal types to USB-C headset page by Danielle Roberts <[email protected]> - 224072758 added row back to the functional patches table by Luke Haviland <[email protected]> - 224053547 Update build numbers for 2018/12 m/s releases by Android Partner Docs <[email protected]> - 224043334 Add WinScope developer documentation by Android Partner Docs <[email protected]> - 224032853 Move localized CDD file to 9 directory by Danielle Roberts <[email protected]> - 224026519 Add Test Mapping docs to Tests Development section by Android Partner Docs <[email protected]> - 223922752 Enhance the documentation for ld.config.txt file format by Android Partner Docs <[email protected]> - 223920489 Devsite localized content from translation request 1040039. by Android Partner Docs <[email protected]> - 223920485 Devsite localized content from translation request 1040022. by Android Partner Docs <[email protected]> - 223857636 Update build numbers for 2018/12 releases by Android Partner Docs <[email protected]> - 223845531 Fix the Qualcomm table to exclude component and only read... by Luke Haviland <[email protected]> - 223816883 Adding the December security bulletins by Luke Haviland <[email protected]> - 223805280 Updated the CDD navigation to include the previous versio... by Luke Haviland <[email protected]> - 223799250 Devsite localized content from translation request 1036673. by Android Partner Docs <[email protected]> - 223799221 Devsite localized content from translation request 1005914. by Android Partner Docs <[email protected]> - 223799216 Devsite localized content from translation request 1015209. by Android Partner Docs <[email protected]> - 223799211 Devsite localized content from translation request 1034359. by Android Partner Docs <[email protected]> - 223587266 Clarify disabled HALs by Android Partner Docs <[email protected]> - 223457102 Devsite localized content from translation request 1034369. by Android Partner Docs <[email protected]> - 223450822 Devsite localized content from translation request 1036675. by Android Partner Docs <[email protected]> - 223365433 Minor style edits by Christina Nguyen <[email protected]> - 223364760 Fix typo. by Christina Nguyen <[email protected]> - 223361317 Devsite localized content from translation request 1018906. by Android Partner Docs <[email protected]> - 223356382 Correct repo location for bluecross kernel by Android Partner Docs <[email protected]> - 223176719 Devsite localized content from translation request 1024867. by Android Partner Docs <[email protected]> - 223176706 Devsite localized content from translation request 1020251. by Android Partner Docs <[email protected]> - 223097181 Devsite localized content from translation request 1013714. by Android Partner Docs <[email protected]> - 222999852 Devsite localized content from translation request 1024727. by Android Partner Docs <[email protected]> - 222999831 Devsite localized content from translation request 1008230. by Android Partner Docs <[email protected]> - 222999739 Devsite localized content from translation request 1022537. by Android Partner Docs <[email protected]> - 222999726 Devsite localized content from translation request 1026861. by Android Partner Docs <[email protected]> - 222999709 Devsite localized content from translation request 1028231. by Android Partner Docs <[email protected]> - 222906457 Add Atest docs to Tests section by Kenneth Lau <[email protected]> - 222886182 Devsite localized content from translation request 1019176. by Android Partner Docs <[email protected]> PiperOrigin-RevId: 225558908 Change-Id: I318551b443def5e3a8f402c1585d0ad4f986276a
diff --git a/zh-cn/compatibility/tests/development/native-func-e2e.html b/zh-cn/compatibility/tests/development/native-func-e2e.html new file mode 100644 index 0000000..17023aa --- /dev/null +++ b/zh-cn/compatibility/tests/development/native-func-e2e.html
@@ -0,0 +1,142 @@ +<html devsite><head> + + <meta name="book_path" value="/_book.yaml"/> + + <meta name="project_path" value="/_project.yaml"/> +</head> +<body> + +<!-- + Copyright 2018 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<h1 id="adding_a_new_native_test_a_complete_example" class="page-title">添加新的原生测试:完整的示例</h1> + +<p>如果您不熟悉 Android 平台开发,那么您可能会发现,这个从头开始添加全新原生测试的完整示例很有用,可以帮助了解所涉及的典型工作流。</p> + +<p>请注意,本指南假定您已掌握平台源代码树工作流的一些相关知识。如果没有,请参阅 https://source.android.com/source/requirements。</p> + +<p>此外,如果您也不熟悉 C++ 的 gtest 框架,请访问 <a href="https://github.com/google/googletest">gtest 项目网站</a>以查看其他文档。</p> + +<p>本指南使用以下测试作为示例:</p> + +<ul> +<li><a href="https://android.googlesource.com/platform/platform_testing/+/master/tests/example/native/">Hello World 原生测试</a></li> +</ul> + +<p>建议您先浏览代码以获得粗略的印象,然后再继续。</p> + +<h2 id="deciding_on_a_source_location">确定源代码所在的位置</h2> + +<p>通常,您的团队已有既定的放置模式,在既定的位置检入代码,并且在既定的位置添加测试。大多数团队拥有单个 git 代码库,或与其他团队共享一个代码库,但有一个包含组件源代码的专用子目录。</p> + +<p>假设组件源代码的根位置是在 <code><component source +root></code>,大多数组件在该位置下具有 <code>src</code> 和 <code>tests</code> 文件夹,以及一些其他文件,如 <code>Android.mk</code>(或拆分为额外的 <code>.bp</code> 文件)。</p> + +<p>由于您要添加全新的测试,因此或许需要在组件 <code>src</code> 旁边创建 <code>tests</code> 目录,并为其填充内容。</p> + +<p>在某些情况下,您的团队可能会在 <code>tests</code> 下设置更深的目录结构,因为需要将不同的测试套件打包到单独的二进制文件中。在这种情况下,您需要在 <code>tests</code> 下创建一个新的子目录。</p> + +<p>为了进行说明,下面给出了具有单个 <code>tests</code> 文件夹的组件的典型目录大纲:</p> +<pre class="prettyprint"><code>\ + <component source root> + \-- Android.bp (component makefile) + \-- AndroidTest.bp (test config file) + \-- src (component source) + | \-- foo.cpp + | \-- ... + \-- tests (test source root) + \-- Android.bp (test makefile) + \-- src (test source) + \-- foo_test.cpp + \-- ... +</code></pre> +<p>此外,下面还给出了具有多个测试源文件目录的组件的典型目录大纲:</p> +<pre class="prettyprint"><code>\ + <component source root> + \-- Android.bp (component makefile) + \-- AndroidTest.bp (test config file) + \-- src (component source) + | \-- foo.cpp + | \-- ... + \-- tests (test source root) + \-- Android.bp (test makefile) + \-- testFoo (sub test source root) + | \-- Android.bp (sub test makefile) + | \-- src (sub test source) + | \-- test_foo.cpp + | \-- ... + \-- testBar + | \-- Android.bp + | \-- src + | \-- test_bar.cpp + | \-- ... + \-- ... +</code></pre> +<p>不管是什么样的结构,您最终都需要在 <code>tests</code> 目录或新建子目录中添加文件,并且文件应类似于示例 gerrit 更改中的 <code>native</code> 目录中的文件。下面几部分将进一步详细说明各个文件。</p> + +<h2 id="blueprints">Blueprint</h2> + +<p>每个新的测试模块都必须具有 Blueprint Soong 配置文件,以使用模块元数据、编译时依赖项和打包指令来指引编译系统。详情请参阅 <a href="blueprints.md">Soong 和 Blueprint</a>。</p> + +<h2 id="source_code">源代码</h2> + +<p>有关示例,请参阅 <a href="https://android.googlesource.com/platform/platform_testing/+/master/tests/example/native/HelloWorldTest.cpp">Hello World 原生测试</a>。</p> + +<p>带注解的源代码如下所示:</p> +<pre class="prettyprint lang-c++"><code>#include <gtest/gtest.h> +</code></pre> +<p>gtest 的头文件。请注意,使用 makefile 中的 <code>BUILD_NATIVE_TEST</code> 会自动解析头文件依赖项</p> +<pre class="prettyprint lang-c++"><code>#include <stdio.h> + +TEST(HelloWorldTest, PrintHelloWorld) { + printf("Hello, World!"); +} +</code></pre> +<p>gtest 使用 <code>TEST</code> 宏编写而成:第一个参数是测试用例名称,第二个是测试名称;在结果信息中心查看时,它们与测试二进制文件名称一起形成下面的层次结构:</p> +<pre class="prettyprint"><code><test binary 1> +| \-- <test case 1> +| | \-- <test 1> +| | \-- <test 2> +| | \-- ... +| \-- <test case 2> +| | \-- <test 1> +| | \-- ... +| \-- ... +<test binary 2> +| +... +</code></pre> +<p>有关使用 gtest 编写测试的更多信息,请参阅其文档:</p> + +<ul> +<li>https://github.com/google/googletest/blob/master/googletest/docs/Primer.md</li> +</ul> + +<h2 id="test_configuration">测试配置</h2> +<aside class="special"><strong>重要提示</strong>:<span>只有 CTS 测试或需要特殊设置(如停用蓝牙或收集示例数据)的测试需要遵循本部分中的说明。其他所有用例均可通过使用 <a href="https://android.googlesource.com/platform/tools/tradefederation/+/master/atest/README.md">Atest</a> 来涵盖。</span></aside> +<p>为了简化测试执行过程,您可以编写类似以下映射的测试映射:<a href="https://android.googlesource.com/platform/platform_testing/+/master/tests/example/native/TEST_MAPPING">/platform/platform_testing/tests/example/native/TEST_MAPPING</a>。</p> + +<p>要改用 Trade Federation,请为 Android 的自动化测试框架 <a href="/devices/tech/test_infra/tradefed/">Trade Federation</a> 编写测试配置文件。</p> + +<p>测试配置可以指定特殊的设备设置选项和默认参数来提供测试类。</p> + +<h2 id="build_and_test_locally">在本地编译和测试</h2> + +<p>对于最常见的用例,请使用 <a href="https://android.googlesource.com/platform/tools/tradefederation/+/master/atest/README.md">Atest</a>。</p> + +<p>对于更为复杂的用例,如果需要更繁琐的自定义,请遵循<a href="instrumentation.md">插桩说明</a>。</p> + +</body></html> \ No newline at end of file