diff options
Diffstat (limited to 'files/ja/archive/b2g_os/automated_testing')
17 files changed, 0 insertions, 2884 deletions
diff --git a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/gaia_ui_tests_run_tests/index.html b/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/gaia_ui_tests_run_tests/index.html deleted file mode 100644 index 488d7af933..0000000000 --- a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/gaia_ui_tests_run_tests/index.html +++ /dev/null @@ -1,356 +0,0 @@ ---- -title: 'Gaia UI Tests: Running Tests' -slug: Archive/B2G_OS/Automated_testing/gaia-ui-tests/Gaia_UI_Tests_Run_Tests -tags: - - Automation - - Firefox OS - - Gaia - - Guide - - Testing - - gaia-ui-test - - gaiatest -translation_of: Archive/B2G_OS/Automated_testing/gaia-ui-tests/Gaia_UI_Tests_Run_Tests ---- -<div><section class="Quick_links" id="Quick_Links"> - -<ol> - <li class="toggle"> - <details> - <summary>Build and install</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS">Build and install overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_build_process_summary">B2G OS build process summary</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/B2G_OS_build_prerequisites">Build prerequisites</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Preparing_for_your_first_B2G_build">Preparing for your first build</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building">Building B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_installer_add-on">B2G installer add-on</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Building_for_Flame_on_OS_X">Building B2G OS for Flame on Mac OS X</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Choosing_how_to_run_Gaia_or_B2G">Choosing how to run Gaia or B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Compatible_Devices">Compatible Devices</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Installing_on_a_mobile_device">Installing B2G OS on a mobile device</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_update_packages">Creating and applying B2G OS update packages</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building/FOTA_community_builds">Building and installing FOTA community builds</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_Build_Variables_Reference_Sheet">B2G build variables reference sheet</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Porting B2G OS</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS">Porting overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/basics">Porting basics</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/Porting_on_CyanogenMod">Porting on CyanogenMod</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Developing Gaia</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia">Developing Gaia overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Running_the_Gaia_codebase">Running the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Mulet">Run Gaia on desktop using Mulet</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Understanding_the_Gaia_codebase">Understanding the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Making_Gaia_code_changes">Making Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Testing_Gaia_code_changes">Testing Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Submitting_a_Gaia_patch">Submitting a Gaia patch</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Build_System_Primer">Gaia build system primer</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Different_ways_to_run_Gaia">Different ways to run Gaia</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/make_options_reference">Make options reference</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Gaia_tools_reference">Gaia tools reference</a></li> - </ol> - </details> - </li> - <li><a href="/ja/docs/Mozilla/B2G_OS/API">B2G OS APIs</a></li> -</ol> -</section></div> - -<div class="summary"> -<p><span class="seoSummary">この記事は、実際のFireFox OS 端末やB2Gデスクトップ、Gaia 自身内部にあるものに合わせた、Gaia UI テストの実行の仕方・流れの詳細を配信してます。Gaia プロジェクトは、コミット毎の継続的インテグレーションとプルリクエストテストをする為に、<a href="https://treeherder.mozilla.org/">Treeherder</a> を使用しています。</span></p> -</div> - -<p>Gaia UI テスト は、実際の端末やエミュレーター、<a href="https://developer.mozilla.org/en-US/Firefox_OS/Using_the_B2G_desktop_client">B2G Desktop </a>クライアントで実行する性能をもって開発されています。もっとずっと簡単な方法は、B2G デスクトップに対して実行させることです。あなたがお使いのFirefox OS のバージョンと対して実行させる為に、Gaia の正しいブランチを選ばないといけないことを、忘れないで下さい。</p> - -<h2 id="sect1"> </h2> - -<h2 id="B2G_デスクトップ上でテスト">B2G デスクトップ上でテスト</h2> - -<p>B2G クラインアントは、次のようなものです。:デスクトップから楽にFirefox OS上でwebアプリケーションのテスト実行に使える、B2Gのデスクトップ・バージョンです。もし、このテストに詳しくなければ、<a href="https://developer.mozilla.org/en-US/Firefox_OS/Using_the_B2G_desktop_client">B2G デスクトップ・クライアント・テストの使用</a>をお読み下さい。この項目では、B2GデスクトップでのUI テストの仕方を教えています。</p> - -<div class="note"> -<p>ショートカット:手作業でのPCの環境設定が嫌でしたら、<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/Automated_testing/MozITP">MozITP</a>を使用できます。このツール・セットは自動で、仮想マシンのUbuntu と、任意のタイミングで1クリックで実物のデバイスやMulet 上でのテストを開始できる、gaia UI テスト環境を準備・設定してくれます。</p> -</div> - -<div> -<h3 id="sect2"> </h3> - -<h3 id="前提条件">前提条件</h3> - -<p> ●デスクトップ版B2G をビルドして下さい。 ご自分のPCか仮想マシンのディレクトリに、<a href="http://nightly.mozilla.org/">こちら</a>(試用版を含む)をダウンロードするか<a href="https://developer.mozilla.org/en-US/Firefox_OS/Using_the_B2G_desktop_client#Building_the_desktop_client">自身でコンパイル</a>し、mozconfig ファイルに、<code>ENABLE_MARIONETTE=1</code> この1行を追加して下さい。</p> - -<p>●<a href="https://github.com/mozilla-b2g/gaia/">Gaia Github repository</a> がクローン(コピー)を生成し、確認します。ここでプロフィールを生成する必要があります。<code>プロフィールの生成をしている間、DEBUG=1 で通過していけないことを、注意して下さい。</code>Gaia プロフィールのデバッグの使用は、Gaia UI テストからB2G デスクトップ・インスタンスへ接続への失敗の原因となります。</p> - -<p>● <code>testvars.json ファイル で以下を確認して下さい。</code></p> - -<p><a href="#Configuring_test_variables">Configuring test variables</a></p> - -<p>実物のデバイスが使用できず、電話レベル機能が必要ない場合、デスクトップ B2G クライアントは、テスト開発に理想的です。テストの実行が速く、入手しやすく、MacやWindows、Linux で行えます!</p> - -<h3 id="テストの実行">テストの実行</h3> - -<p>新しいテストの実行を確認して見ていきましょう。自分達の変更点が即拾い上げられるように、私達は、Gaia のリポジトリーから直接、gaiatest の作業tree内のバージョンをインストールしています。あなたがクローンを生成したGaiaのバージョンで、<code>gaia/tests/python/gaia-ui-tests</code> へ移動し、下記の設定のコマンドを実行して下さい。</p> - -<pre class="brush: bash line-numbers language-bash"><code class="language-bash">python setup.py develop</code></pre> - -<p>これは、仮想環境内で実行されない時、権限の拒否によるエラーを与えることがあります。その場合では、まだインストールされていないなら <code>virtualenv</code> と <code>virtualenvwrapper</code> をインストールします。</p> - -<pre>pip install virtualenv -pip install virtualenvwrapper (perhaps need to use sudo here) -export WORKON_HOME=~/Envs -source /usr/local/bin/virtualenvwrapper.sh -<code class="java plain">echo </code><code class="java string">"source /usr/local/bin/virtualenvwrapper.sh"</code> <code class="java plain">>> .bash (rc or _profile)</code></pre> - -<p>それから、仮想環境を作って入って下さい。</p> - -<pre><code>mkvirtualenv gaia-ui-test</code></pre> - -<p>私達がテストを始める場合、Marionette経由で <code>gaiatest</code> はB2Gデスクトップを起動できます。これをするには、B2GバイナリーファイルとB2Gプロファイルへのパスを渡しておく必要があります。下記の例では <code>$HOME</code> 変数に <code>b2g</code> バイナリーと b2g プロファイルを含めています。これは単に、B2Gデスクトップをダウンロード後に、zip展開した場所です。全てのテストを実行するコマンドは下記の通り:</p> -</div> - -<pre class="brush: bash">gaiatest --binary=$HOME/b2g/b2g-bin --profile=$HOME/b2g/gaia/profile --testvars=testvars.json --restart --type=b2g ./gaiatest/tests/functional/manifest.ini -</pre> - -<p>B2G デスクトップに互換性のないテスト — 例えば電話をかけたりSMS送信したりするもの — はテスト実行から自動的に省かれます。</p> - -<p>コマンドライン上でファイルを直接呼んでテスト実行できます:</p> - -<pre class="brush: bash">gaiatest --binary=$HOME/b2g/b2g-bin --profile=$HOME/b2g/gaia/profile --testvars=testvars.json --restart ./gaiatest/tests/functional/clock/test_clock_set_alarm.py -</pre> - -<h2 id="Firefox_OS_デバイスの上でのテスト">Firefox OS デバイスの上でのテスト</h2> - -<p><span style="line-height: 1.5;">実際のFirefox OSデバイス上でのテストは、より複雑です。しかし、テストの中で実際のデバイス上でAPIにアクセスする(+ etc...)ため、より正確な結果を得る事ができます。全てのデバイスAPIや、ハードウェア機能といったものへアクセスできます。しなしながら、Firefox OS の実端末を持っていない場合や、使っている機能が実際のハードウェアを必要としない場合は、エミュレータ内で一般機能をテストすることもできます。</span></p> - -<div class="note"> -<p>If you don't want to setup the environment manually. You can try <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/Automated_testing/MozITP">MozITP</a>, it will automatically setup a pre-configured Ubuntu VM and Gaia UI Test environment, so you can start testing on real device or simulator in one-click.</p> -</div> - -<p><font size="5"><span style="letter-spacing: -0.5px; line-height: 24px;">前提条件</span></font></p> - -<div> -<ul> - <li><a href="/en-US/Firefox_OS/Debugging/Installing_ADB">Android Debug Bridge</a> がPCにインストールされていること、<a href="/en-US/Firefox_OS/Firefox_OS_build_prerequisites#For_Linux.3A_configure_the_udev_rule_for_your_phone">udev rules configured</a> が済んでいること</li> - <li>Marionetteが有効になっているビルドのソフトがフラッシュされた、Firefox OSデバイス</li> - <li>あなたのFirefox OSデバイスにフラッシュされたソフトをビルドした際、cloneしてcheck outしたものと同じブランチの、gaiaレポジトリ (<a href="https://github.com/mozilla-b2g/gaia/">Gaia Github repository</a>) </li> - <li><a href="#testvars">testvars.json ファイル</a> (詳しくは、他の関連セクションで説明されています)</li> -</ul> -</div> - -<h3 id="テストを実行する">テストを実行する</h3> - -<p>The gaiatest package is needed to run the tests. We need to install this for the branch that we want to run the tests on. Navigate to the <code>gaia/tests/python/gaia-ui-tests/</code> directory and install gaiatest with this command:</p> - -<pre class="brush: bash line-numbers language-bash"><code class="language-bash">python setup.py develop</code></pre> - -<div class="note"> -<p><strong>Note</strong>: Before you start to run the test, read through <a href="http://gaiatest.readthedocs.org/en/latest/testrunner.html#risks" title="https://developer.mozilla.org/en-US/docs/Gaia_Test_Runner#Risks">this warning</a> in order to acknowledge that running gaia-ui-tests on a device may cause data to be deleted from the device!</p> -</div> - -<div class="note"> -<p><strong>Debug Firefox OS builds: </strong>Firefox OS builds built with DEBUG=1 will need a greater timeout than the default (20 seconds). Try adding to the command line --timeout 60000 or higher, depending upon the speed of the device.</p> -</div> - -<p>Marionette on the device awaits commands on port 2828. We need to forward our local port to the remote port on the device using adb. Run the following command:</p> - -<pre class="brush: bash line-numbers language-bash"><code class="language-bash">adb forward tcp:2828 tcp:2828</code></pre> - -<p>Please be reminded that you'll need to start your emulator before the command, if you are not running on a real Firefox OS device.</p> - -<p>You can use the following command to execute all the gaia-ui-tests:</p> - -<pre class="brush: bash line-numbers language-bash"><code class="language-bash">gaiatest --address=localhost:2828 --testvars=<TESTVARS_FILE> --restart --type=b2g gaiatest/tests/functional/manifest.ini</code></pre> - -<p>Or use the following if you want to run a single test (substituting the last part for the actual test you want to run):</p> - -<pre class="brush: bash line-numbers language-bash"><code class="language-bash">gaiatest --address=localhost:2828 --testvars=<TESTVARS_FILE> --restart gaiatest/tests/functional/clock/test_clock_create_new_alarm.py</code></pre> - -<p>After the test, you will see all the pass/fail results and stacktraces for each file.</p> - -<h2 id="Gecko_とGaia_開発者向けの_Treeherder_を用いてテストを行う">Gecko とGaia 開発者向けの Treeherder を用いてテストを行う</h2> - -<p>In this section we will focus upon replicating a Treeherder test locally. Before testing locally with a Treeherder configuration, you need to be aware that it builds a Gaia profile separately. The profile that comes packaged with the Treeherder build or rel-eng build is NOT the same Gaia profile that Treeherder uses.</p> - -<div> -<h3 id="前提条件_2">前提条件</h3> - -<ul> - <li>A B2G desktop build. You can either <a href="http://nightly.mozilla.org/">download</a> it (including from a Try push) and unpack to a directory on your computer or virtual machine or <a href="https://developer.mozilla.org/en-US/Firefox_OS/Using_the_B2G_desktop_client#Building_the_desktop_client">compile it yourself</a>, with the addition of <code>ENABLE_MARIONETTE=1</code> in your mozconfig.</li> - <li>The <a href="https://github.com/mozilla-b2g/gaia/">Gaia Github repository</a> checked out (for making the Gaia profile, and installing gaiatest and the test files).</li> - <li>A <code>testvars.json</code> file; see <a href="#Configuring_test_variables">Configuring test variables</a>.</li> -</ul> -</div> - -<h3 id="Treeherder_設定を使って_Gaia_プロファイルを作成する">Treeherder 設定を使って Gaia プロファイルを作成する</h3> - -<p>Before building a profile we need to check the environment variables that were used to build the profile. Searching in the "brief log" of the Gu test run, find this command block:</p> - -<pre class="brush: bash line-numbers language-bash"><code class="language-bash">Using env: {'DEBUG': '0', - 'DESKTOP': '0', - 'DESKTOP_SHIMS': '0', - 'NOFTU': '0'}</code></pre> - -<p>These settings can drastically change the way desktop B2G behaves. It is very important to match Treeherder's settings.</p> - -<p>The next step is to checkout the git commit that matches the hg commit that Treeherder ran with. You can also find the hg commit in the "brief log" of the Treeherder run but you will need to correlate that with the git commit yourself.</p> - -<p>The gaia test repository includes a <code>make</code> script for building a Gaia profile. Navigate to the Gaia repo that you have cloned locally, and build the profile using the environment variables we found on Treeherder:</p> - -<pre class="brush: bash line-numbers language-bash"><code class="language-bash">DEBUG=0 DESKTOP=0 DESKTOP_SHIMS=0 NOFTU=0 make</code></pre> - -<h3 id="テストを実行する_2">テストを実行する</h3> - -<p>Using the same git commit that Treeherder used to run the test, go to the <code>gaia/tests/python/gaia-ui-tests</code> directory and install gaiatest using the following command:</p> - -<pre class="brush: bash line-numbers language-bash"><code class="language-bash">python setup.py develop</code></pre> - -<p>Now that you have built the Gaia profile, the only significant difference to running these tests is that you must direct gaiatest to the binary location and profile location.</p> - -<p>Inside the <code>gaia-ui-tests</code> directory, run the below command, with the following substitutions made:</p> - -<ul> - <li><code>$BINARY_PATH</code>: The path to the <code>b2g-bin</code> file in the directory you have built or unpacked desktop B2G to.</li> - <li><code>$PROFILE_PATH</code>: The path to your locally build Gaia profile. If built from the Gaia repository it will be <code>~/gaia/profile</code>.</li> -</ul> - -<pre class="brush: bash line-numbers language-bash"><code class="language-bash">gaiatest --binary $BINARY_PATH/b2g/b2g-bin --profile $PROFILE_PATH/profile --restart --testvars testvars.json gaiatest/tests/manifest.ini --type=b2g</code></pre> - -<div class="note"> -<p><strong>Note</strong>: There is no need to forward port 2828 unless you have set the Marionette server to use a different default port.</p> -</div> - -<div class="warning"> -<p><strong>Important</strong>: Try to keep your mouse cursor clear of the b2g window so that pointer events do not pollute the test run.</p> -</div> - -<h3 id="入り組んだ_Treeherder_ジョブの中から_HTML_レポートを見つける">入り組んだ Treeherder ジョブの中から HTML レポートを見つける</h3> - -<p>All Treeherder jobs (both pass and fail) have an HTML report output generated and stored.</p> - -<ol> - <li>For the commit and <em>Gip</em> job, click the chunk of interest (e.g., f1, f2).</li> - <li>In the status bar at the bottom of the screen find the section titled: <strong><label>artifact uploaded</label></strong> <span> <span class="ng-binding ng-scope">output.html</span></span>.</li> - <li>Click link to view the report.</li> -</ol> - -<h2 id="既に実行済みのデスクトップ_B2G_バイナリをテストする">既に実行済みのデスクトップ B2G バイナリをテストする</h2> - -<p>In this section we will look at running the tests against an already running Desktop B2G binary with modified source code.</p> - -<div> -<h3 id="前提条件_3">前提条件</h3> - -<ul> - <li>A B2G desktop build with your Gecko changes. You can either <a href="http://nightly.mozilla.org/">download</a> it (including from a Try push) and unpack to a directory on your computer or virtual machine or <a href="https://developer.mozilla.org/en-US/Firefox_OS/Using_the_B2G_desktop_client#Building_the_desktop_client">compile it yourself</a>, with the addition of <code>ENABLE_MARIONETTE=1</code> in your mozconfig.</li> - <li>Your debugger of choice attached to the B2G binary.</li> - <li>The <a href="https://github.com/mozilla-b2g/gaia/">Gaia Github repository</a> checked out (for installing gaiatest and the test files).</li> - <li>A <code>testvars.json</code> file; see <a href="#Configuring_test_variables">Configuring test variables</a>.</li> -</ul> -</div> - -<h3 id="テストを実行する_3">テストを実行する</h3> - -<p>Running tests against an existing b2g process is quite easy — you've already gone through the hard parts to build B2G!</p> - -<p>If you have not already installed gaiatest then do so now by going to <code>gaia/tests/python/gaia-ui-tests</code> and running the following:</p> - -<pre class="brush: bash line-numbers language-bash"><code class="language-bash">python setup.py develop</code></pre> - -<p>Once you have started the b2g binary process and attached your debugger you need to direct gaiatest to the port using the <code>--address</code> command. Do not use <code>--binary</code> or <code>--profile</code>, otherwise gaiatest will just send commands directly to the port without attempting to start or close the binary.</p> - -<pre class="brush: bash line-numbers language-bash"><code class="language-bash">gaiatest --testvars testvars.json gaiatest/tests/functional/test_that_is_being_debugged.py</code></pre> - -<div class="note"> -<p><strong>Note</strong>: We have omitted the <code>--restart</code> command too. As gaiatest does not attempt to stop or start the binary, some data from your test run may be left behind in Firefox OS databases or even in the DOM. It is your responsibility to reset B2G back to a basic state before trying to run the test for a second time.</p> -</div> - -<h2 id="テスト変数を設定する">テスト変数を設定する</h2> - -<p>You can customize variables used during the test using a <code>testvars.json</code> file. The gaia-ui-tests will wipe the databases on your phone in order to give the test a clean profile to run against. Gaiatest contains protection against running and wiping your device's data. Please read <a href="https://developer.mozilla.org/en-US/docs/Gaia_Test_Runner#Risks" title="https://developer.mozilla.org/en-US/docs/Gaia_Test_Runner#Risks">the warning</a> before you set up your test variables file.</p> - -<p>We use the <code>--testvars</code> option to pass in local variables, particularly those that cannot be checked into the repository. For example in gaia-ui-tests these variables can be your private login credentials, phone number, or details of your WiFi connection.</p> - -<p>To use it, copy <code>testvars_template.json</code> to a different filename but add it into <code>.gitignore</code> so you don't check it into your repository.</p> - -<p>When running your tests add the argument: <code>--testvars=(filename).json</code></p> - -<h3 id="(端末用の)_testvars.json_を使って_WiFi_設定する方法">(端末用の) testvars.json を使って WiFi 設定する方法</h3> - -<p>By setting the WiFi key in <code>testvars.json</code> you can configure the Firefox OS Settings database with your WiFi configuration. Then the test cases can use your WiFi connection.</p> - -<p>No WiFi authentication:</p> - -<pre><code class="brush: bash">"wifi": { "ssid": "MyNetwork"} </code></pre> - -<p>WEP authentication:</p> - -<pre><code>"wifi": { "ssid": "MyNetwork", "keyManagement": "WEP", "wep": "MyPassword" } </code></pre> - -<p>WPA-PSK authentication:</p> - -<pre><code>"wifi": { "ssid": "MyNetwork", "keyManagement": "WPA-PSK", "psk": "MyPassword" } </code></pre> - -<div class="note"> -<p><strong>Note:</strong> Due to <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=775499" title="FIXED: [Wifi] Support subject_match to WPA-EAP Enterprise networks">バグ 775499</a>, WiFi connections via WPA-EAP are not possible at this time.</p> -</div> - -<h2 id="トラブルシューティング">トラブルシューティング</h2> - -<p>この節では、いくつかのよくあるエラーメッセージを、潜在的な解決策を挙げつつ解説します。</p> - -<h3 id="テスト開始前によくある問題">テスト開始前によくある問題</h3> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col" style="text-align: center;"><strong>エラーメッセージ</strong></th> - <th scope="col" style="text-align: center;">対応策</th> - </tr> - </thead> - <tbody> - <tr> - <td>error: [Errno 111] Connection refused</td> - <td> - <p>"adb forward tcp:2828 tcp:2828" コマンドを再発行する<br> - <br> - B2G プロセスが実行されていない</p> - </td> - </tr> - <tr> - <td>Element ... not visible before timeout</td> - <td>テストするアプリにて、要素(element)が表示されている事を確認する</td> - </tr> - <tr> - <td>TimeoutException: Condition timed out</td> - <td>アプリの条件が、期待しているのと同じである事を確認する</td> - </tr> - <tr> - <td>marionette.errors.MarionetteException: localhost:2828 is unavailable.</td> - <td>何者か、よくあるのが `adb forward` コマンドがポートをブロックしている。`adb kill-server` で解決するか、アプリを停止することでポートは開放される</td> - </tr> - <tr> - <td>ImportError: No module named bluetooth</td> - <td> - <p>コマンド内で、 <code>--type=b2g</code> を<br> - <code>--type=b2g-bluetooth</code><br> - に置き換える、あるいは pybluez Python bluetooth パッケージをインストールする</p> - </td> - </tr> - <tr> - <td>OSError: [Errno 2] No such file or directory: '~/moz/gaia/profile'</td> - <td>コマンドラインにて、 $HOME のつもりで ~ を使っていないかどうか確認する</td> - </tr> - </tbody> -</table> - -<p> </p> diff --git a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/index.html b/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/index.html deleted file mode 100644 index 430bef3bb9..0000000000 --- a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/index.html +++ /dev/null @@ -1,73 +0,0 @@ ---- -title: Gaia UI テストの導入 -slug: Archive/B2G_OS/Automated_testing/gaia-ui-tests -tags: - - Build documentation - - Firefox OS - - Gaia - - Guide - - Mobile - - Testing - - TopicStub - - gaia-ui-test - - gaiatest -translation_of: Archive/B2G_OS/Automated_testing/gaia-ui-tests ---- -<p></p><div class="prevnext" style="text-align: right;"> - <p><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_1_Marionette_Firefox_OS_start">次のページ »</a></p> -</div><p></p> - -<div class="summary"> -<p>Gaia-ui-tests は、Gaia (Firefox OSのUI) を隅から隅までUIテスト実行するMozillaのテストスイートです。全てのテストはPythonで書かれ、Firefox OSのAPI操作に使う JavaScript もいくらか混じっています。このチュートリアル記事では、テストを書いて実行する環境のセットアップ方法を説明します。</p> -</div> - -<p>Gaia-ui-tests は <strong>Gaiatest</strong>という、<a href="/docs/Mozilla/QA/Marionette" title="https://developer.mozilla.org/en-US/docs/Marionette">Marionette</a> あたりを元にしたPythonパッケージを使っています。 Gaiatest はHTML ロケータや、Marionette 呼び出しや、(相互コミュニケーションと機能用の)API呼び出しを一緒にラップすろように設計されています。Marionette は、<a href="http://docs.seleniumhq.org/projects/webdriver/" title="http://docs.seleniumhq.org/projects/webdriver/">Selenium WebDriver</a> (ブラウザ自動化のプログラミングインターフェイス) 用に開発されたW3C標準に基いています。WebDriver と page/app オブジェクトを以前使った事がある場合、Marionette と gaiatest を使うのは楽に感じるでしょう。</p> - -<h2 id="Gaia_UI_を開始する">Gaia UI を開始する</h2> - -<p>Gaia/Firefox OS の自動テストを開始するのに熱心な人のために、何もない所から自身のテストを書き始めるのを助けるチュートリアル集を用意しています。このチュートリアルをいったん終えてしまうと、Mozillaのテスト貢献者を始めるための、テストや、Firefox OS や、Marionette に対する充分な知識が得られるでしょう。<strong>貢献者になりたい場合は、このチュートリアルを完了しておくことを強く推奨します。</strong></p> - -<dl> - <dt><a href="/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_1_Marionette_Firefox_OS_start">パート 1: Marionette と Firefox OS をはじめよう</a></dt> - <dd>この記事には、テスト実行を開始するためにインストールが必要となるツール、たとえば B2G デスクトップ、Python、Marionette が載っています。</dd> - <dt><a href="/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_2_Marionette_Firefox_OS_interactions">パート 2: Marionette を使って Firefox OS と基本的なやりとりをする</a></dt> - <dd>Marionette 経由で Firefox OS を操作するために使う基本コマンドをざっと見ます。</dd> - <dt><a href="/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_3_Reusable_tests">パート 3: コードを再利用可能テストに更新する</a></dt> - <dd>まだまだ行こう、この記事では基本的なコマンドをPythonファイル内のシンプルなテストに組み上げて、単一エントリーから全てを実行できるようにします。</dd> - <dt><a href="/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_4_Reusing_commands_Firefox_OS_setup">パート 4: Firefox OS をセットアップする再利用コマンド</a></dt> - <dd>ここではコマンドをPythonメソッドに変えて再利用しやすくするのを見て行きます。</dd> - <dt><a href="/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_5_Introducing_a_test_runner">パート 5: テストランナーを導入する</a></dt> - <dd>テストランナーは優秀なテストスイートの中心的機能で、これにより複数のテストの実行やレポートや結果の集約ができます。この記事ではPythonのユニットテストランナーの基本を探検します。</dd> - <dt><a href="/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_6_Marionette_By_class">パート 6: クラスによって、タプルと Marionette を使う</a></dt> - <dd>ここでは、更にコードの重複を削減する方法を説明します、それにはタプル内の繰り返しのロケーターを保管して Marionetteの <code>By</code> クラスの文法でシンプルにします。</dd> - <dt><a href="/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_7_Writing_your_own_tests">パート 7: 自分自身のテストを書く</a></dt> - <dd>いま基本は備わっています、そして自分自身のテストを書く時です! ここでは作業を簡単にする推奨ツールの予定や、手で書いてみるいくつかのテストをお勧めします。</dd> - <dt><a href="/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_8_Using_a_base_class">パート 8: ベースクラスを使用する</a></dt> - <dd>この状態では、テストファイルは全てのテストランナーコードを含んでいます。当面は問題ないですが、テストファイルの実行を始めるとすぐに、多くの複製ができるでしょう。テストランナーコードを別々のPythonクラスに分けて抽象化する事で、この問題を解決してみます。</dd> - <dt><a href="/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_9_app_objects">パート 9: アプリオブジェクトの複製を抑える</a></dt> - <dd>コードのメンテナンス性についての最終改良として、この記事では特定のFirefox OSアプリとのインタラクションをPythonアプリオブジェクトに抽象化するという抽象化を探検します。</dd> -</dl> - -<h2 id="上級トピック">上級トピック</h2> - -<p>テストの実行と記述をものにしたら、もっと複雑・先進的な作業に移りたくなるでしょう、例えば gaia-ui-tests 全体のテストスイートを実行したり、テスト結果としてpower drawをログ出力したり。</p> - -<dl> - <dt><a href="/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Gaia_UI_Tests_Run_Tests" title="Gaia UI Tests Run Tests">gaia-ui-tests を実行する</a></dt> - <dd>Firefox OS の実端末や<a href="/en-US/Firefox_OS/Using_the_B2G_desktop_client">B2G Desktop</a> に対して、いろいろな設定にて、gaia-ui-tests を一通り実行するガイド。</dd> -</dl> - -<h2 id="こちらも見よ">こちらも見よ</h2> - -<p><a href="https://github.com/mozilla-b2g/gaia/tree/master/tests/python/gaia-ui-tests">Gaia-ui-tests main repository</a></p> - -<h2 id="質問コメント関心事"><span class="mw-headline" id="Questions.2FComments.2FConcerns">質問/コメント/関心事</span></h2> - -<p>このプロジェクトははるかに初期の段階なので、あなたのフィールドバックはとても感謝されます:</p> - -<ul> - <li><a href="http://mailto:_gaia-ui-automation@mozilla.org">gaia-ui-automation@mozilla.org</a> のMLにメールを送って下さい。</li> - <li>あるいは、<a href="https://wiki.mozilla.org/IRC">Mozilla IRC</a> の #fxosqa、#fxos-automation、#moztpeqa といったチャンネルで我々を見つけて下さい。</li> -</ul> - -<div id="divLookup" style="background-color: transparent; color: #000000; position: absolute; top: 308px; left: 98px; padding: 0px; border-radius: 2px;"><img></div> diff --git a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_1_marionette_firefox_os_start/index.html b/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_1_marionette_firefox_os_start/index.html deleted file mode 100644 index 4cf4177291..0000000000 --- a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_1_marionette_firefox_os_start/index.html +++ /dev/null @@ -1,191 +0,0 @@ ---- -title: 'パート 1: Marionette と Firefox OS を開始する' -slug: >- - Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_1_Marionette_Firefox_OS_start -tags: - - Automation - - Firefox OS - - Gaia - - Python - - gaia-ui-test - - tests -translation_of: >- - Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_1_Marionette_Firefox_OS_start ---- -<p></p><section class="Quick_links" id="Quick_Links"> - -<ol> - <li class="toggle"> - <details> - <summary>Build and install</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS">Build and install overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_build_process_summary">B2G OS build process summary</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/B2G_OS_build_prerequisites">Build prerequisites</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Preparing_for_your_first_B2G_build">Preparing for your first build</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building">Building B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_installer_add-on">B2G installer add-on</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Building_for_Flame_on_OS_X">Building B2G OS for Flame on Mac OS X</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Choosing_how_to_run_Gaia_or_B2G">Choosing how to run Gaia or B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Compatible_Devices">Compatible Devices</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Installing_on_a_mobile_device">Installing B2G OS on a mobile device</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_update_packages">Creating and applying B2G OS update packages</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building/FOTA_community_builds">Building and installing FOTA community builds</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_Build_Variables_Reference_Sheet">B2G build variables reference sheet</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Porting B2G OS</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS">Porting overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/basics">Porting basics</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/Porting_on_CyanogenMod">Porting on CyanogenMod</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Developing Gaia</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia">Developing Gaia overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Running_the_Gaia_codebase">Running the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Mulet">Run Gaia on desktop using Mulet</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Understanding_the_Gaia_codebase">Understanding the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Making_Gaia_code_changes">Making Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Testing_Gaia_code_changes">Testing Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Submitting_a_Gaia_patch">Submitting a Gaia patch</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Build_System_Primer">Gaia build system primer</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Different_ways_to_run_Gaia">Different ways to run Gaia</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/make_options_reference">Make options reference</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Gaia_tools_reference">Gaia tools reference</a></li> - </ol> - </details> - </li> - <li><a href="/ja/docs/Mozilla/B2G_OS/API">B2G OS APIs</a></li> -</ol> -</section><p></p> - -<p></p><div class="prevnext" style="text-align: right;"> - <p><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests" style="float: left;">« 前のページ</a><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_2_Marionette_Firefox_OS_interactions">次のページ »</a></p> -</div><p></p> - -<div class="summary"> -<p><span class="seoSummary">このチュートリアルシリーズは、<a href="/docs/Mozilla/QA/Marionette">Marionette</a>(お使いのコンピュータ上で実行される自動化パッケージ)を使用してFirefox OSの自動UIテストを記述し、実行することが軌道に乗ることを目指します。Marionette はGeckoベースのプラットフォームでテストを実行するコマンドを発行します。この特定の記事では、テスト実行を開始する前に行う必要がある設定を一通り行います。</span></p> -</div> - -<p>チュートリアルシリーズでは自動テストの概念を一通り見て、またFirefox OS(かなり有用な<a href="/Firefox_OS/Using_the_B2G_desktop_client">B2G Desktop</a>テストツール含みます)とMarionetteとの動作を紹介します。 時折、独自の解決策を模索することを奨励するための課題が含まれます。</p> - -<div class="note"> -<p><strong>注意</strong>: チュートリアルでは、Mozilla製品に固有のものではありません; 例えば、HTML5のアプリを開発している場合は、テストフレームワークを構築するために、このチュートリアルを使用することができます。</p> -</div> - -<h2 id="このチュートリアルに対するソフトウェア要求">このチュートリアルに対するソフトウェア要求</h2> - -<p>チュートリアルで以下のソフトウェアをインストールして、使用します。:</p> - -<ul> - <li>Python 2.7</li> - <li>pip installer</li> - <li>A text editor or IDE to write code in</li> - <li>The Boot2Gecko desktop client (Firefox OS)</li> - <li>The Marionette client (WebDriver client for Firefox OS)</li> -</ul> - -<h2 id="Python_と_pip">Python と pip</h2> - -<p>Linuxのような一部のオペレーティングシステムはプリインストールのPythonが付属します。 Pythonのをインストールする前に、すでにそれがインストールされていないことを確認してください。コマンドラインまたは端末から、こう実行してください:</p> - -<pre class="brush: bash">python --version</pre> - -<p>Pythonのの2.6.xまたは2.7.xのすべてのバージョンは、このチュートリアルのための申し分ありません。Python2.7がインストールされていない場合は、<a href="https://www.python.org/download/releases/2.7.6/">Python release site</a>でインストーラを見つけることができます。</p> - -<p>Pip はPythonのツールをインストールするために使用され、Marionetteをインストールするにはこれが必要です。端末またはコマンドラインに<code> pip と</code>入力することで、pip がインストールされているかどうか確認することができます。ピップをインストールするには、<a href="http://pip.readthedocs.org/en/latest/installing.html">pip documentation</a>での指示に従ってください。</p> - -<h2 id="B2G_Desktop">B2G Desktop</h2> - -<p>B2Gデスクトップクライアントを使用すると、Gaia (Firefox OSの UI) と、デスクトップまたはラップトップコンピュータ上のFirefoxのOSアプリを実行することができます。 デスクトップクライアントにはいくつかの制限があります — それはカメラ、バッテリー、などのデバイスのハードウェアをエミュレートしていません — しかし、それはこのチュートリアルでの目的にとっては完璧でしょう。次にこれをインストールしましょう。</p> - -<p><a href="http://nightly.mozilla.org/">Firefox Nightly site</a>から最新B2Gデスクトップをダウンロードしてください。(一番下の Desktop Boot2Gecko を見てください) B2Gデスクトップをダウンロードしたら、コンピュータ上のフォルダに内容を抽出します。FirefoxのOSシミュレータを起動するには、お使いのOSに適切な<strong> b2g </strong>スクリプトファイルを実行します。:</p> - -<ul> - <li><strong>Linux</strong>: それを抽出したフォルダに移動し、こう実行します <code>./b2g</code></li> - <li><strong>Mac</strong>: アプリケーションフォルダにB2G.appをドラッグアンドドロップし、そこから実行します。</li> - <li><strong>Windows</strong>: zipファイルを抽出したディレクトリ内からb2g.exeを実行します。</li> -</ul> - -<p>アプリケーションが起動したら、このようなウィンドウが表示されるはずです:</p> - -<p><img alt="A welcome screen for Firefox OS - says welcome in multiple languages" src="https://mdn.mozillademos.org/files/7207/b2g-start-screen.png" style="display: block; height: 509px; margin: 0px auto; width: 322px;"></p> - -<p>Firefox OSのホームスクリーンに到達するまで、初回の使用上の手順に従ってください。次の非常に有用なキーボードコマンドを使って、携帯電話のハードウェアボタンをエミュレートできることに注意してください。(例えば、 ホームを押すと、スリープからの電話を復帰します。)</p> - -<table class="standard-table"> - <thead> - <tr> - <th scope="row"> - <p> </p> - </th> - <th scope="col"> - <p>Windows/Linux キーボード</p> - </th> - <th scope="col"> - <p>Mac OS キーボード</p> - </th> - </tr> - </thead> - <tbody> - <tr> - <th scope="row"> - <p>ホームボタン</p> - </th> - <td> - <p>Home</p> - </td> - <td> - <p>Fn+左矢印</p> - </td> - </tr> - <tr style="height: 0px;"> - <th scope="row"> - <p>電源ボタン</p> - </th> - <td> - <p>End</p> - </td> - <td> - <p>Fn+右矢印</p> - </td> - </tr> - <tr> - <th scope="row"> - <p>音量 +/-</p> - </th> - <td> - <p>Page up/page down</p> - </td> - <td> - <p>Fn+ 上/下 矢印</p> - </td> - </tr> - </tbody> -</table> - -<p>この時点では、B2Gデスクトップを開いたまま残すことができ、側にウィンドウを移動します。次に、Marionetteがインストールされると作業完了です。</p> - -<h2 id="Marionette">Marionette</h2> - -<p>Marionetteは、2つの部分から構成されています。つまりクライアント (ラップトップ上で操作するもの) とサーバ (Firefox OS内で操作するもの)です。操り人形師のように、Marionette サーバで直接Firefox OSを制御できます。</p> - -<p><img alt="marionette architecture showing marionette server inside Firefox OS and marionette client on its own outside" src="https://mdn.mozillademos.org/files/7223/marionette-basic-diagram.png" style="display: block; height: 186px; margin: 0px auto; width: 352px;"></p> - -<p>いまはデスクトップB2Gクライアントを使用しているので、Marionetteサーバがプリインストールされています(実デバイス用のFirefox OSのエンジニアリング構成のビルドを使用している場合も同様です)。 ただしFirefoxのOSを制御する前に、ローカルコンピュータ上にMarionetteのクライアントをインストールする必要があります。これは、ターミナルで次のコマンドを実行することによって行われます:</p> - -<pre class="brush: bash">pip install marionette_client</pre> - -<p>今のところここまでです。セットアップ済みで、発進の準備ができています!</p> - -<p> </p> - -<div id="divLookup" style="background-color: transparent; color: #000000; position: absolute; top: 1308px; left: 106px; padding: 0px; border-radius: 2px;"><img></div> diff --git a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_2_marionette_firefox_os_interactions/index.html b/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_2_marionette_firefox_os_interactions/index.html deleted file mode 100644 index 712caed611..0000000000 --- a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_2_marionette_firefox_os_interactions/index.html +++ /dev/null @@ -1,177 +0,0 @@ ---- -title: 'パート 2: Marionette を使って Firefox OS と基本的なやりとりをする' -slug: >- - Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_2_Marionette_Firefox_OS_interactions -tags: - - Automation - - Firefox OS - - Gaia - - Python - - gaia-ui-tests - - tests -translation_of: >- - Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_2_Marionette_Firefox_OS_interactions ---- -<p></p><section class="Quick_links" id="Quick_Links"> - -<ol> - <li class="toggle"> - <details> - <summary>Build and install</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS">Build and install overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_build_process_summary">B2G OS build process summary</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/B2G_OS_build_prerequisites">Build prerequisites</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Preparing_for_your_first_B2G_build">Preparing for your first build</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building">Building B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_installer_add-on">B2G installer add-on</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Building_for_Flame_on_OS_X">Building B2G OS for Flame on Mac OS X</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Choosing_how_to_run_Gaia_or_B2G">Choosing how to run Gaia or B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Compatible_Devices">Compatible Devices</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Installing_on_a_mobile_device">Installing B2G OS on a mobile device</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_update_packages">Creating and applying B2G OS update packages</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building/FOTA_community_builds">Building and installing FOTA community builds</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_Build_Variables_Reference_Sheet">B2G build variables reference sheet</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Porting B2G OS</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS">Porting overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/basics">Porting basics</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/Porting_on_CyanogenMod">Porting on CyanogenMod</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Developing Gaia</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia">Developing Gaia overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Running_the_Gaia_codebase">Running the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Mulet">Run Gaia on desktop using Mulet</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Understanding_the_Gaia_codebase">Understanding the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Making_Gaia_code_changes">Making Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Testing_Gaia_code_changes">Testing Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Submitting_a_Gaia_patch">Submitting a Gaia patch</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Build_System_Primer">Gaia build system primer</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Different_ways_to_run_Gaia">Different ways to run Gaia</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/make_options_reference">Make options reference</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Gaia_tools_reference">Gaia tools reference</a></li> - </ol> - </details> - </li> - <li><a href="/ja/docs/Mozilla/B2G_OS/API">B2G OS APIs</a></li> -</ol> -</section><p></p> - -<p></p><div class="prevnext" style="text-align: right;"> - <p><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_1_Marionette_Firefox_OS_start" style="float: left;">« 前のページ</a><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_3_Reusable_tests">次のページ »</a></p> -</div><p></p> - -<div class="summary"> -<p><span class="seoSummary">チュートリアルのパート2では、Firefox OSのリモート制御を可能にするいくつかの簡単なMarionetteのコマンドを始めましょう。完全なテスト記述はカバーしていませんが、テストを書くときに使用する基本的なコードの特徴を教えてくれます。パート3では、このコードを実際のテストに進化させるように進行します。</span></p> -</div> - -<h2 id="Firefox_OSをスタートアップ">Firefox OSをスタートアップ</h2> - -<p>これらのテストを書くとき、Firefox OSをすでに実行し、コマンドを受信する準備をしている必要があります:</p> - -<ol> - <li>デスクトップB2Gを起動します</li> - <li><em>Settings App > Screen lock > uncheck Lock screen</em>を使用して、ロックスクリーンを無効にします。</li> - <li><em>Settings App > Display > Screen timeout</em> の設定を <em>never </em>に変更することによって、画面のタイムアウト/スリープモードを無効にします</li> - <li>我々のテストコマンドを待つために、横側にウィンドウを移動させます</li> -</ol> - -<h2 id="Marionetteを発射">Marionetteを発射</h2> - -<p>今、Pythonコンソールを起動します: 単にターミナルウィンドウに移動して、<code>python</code>コマンドを発行します。</p> - -<p>ここからは、Firefox OSの内部のMarionetteのサーバにコマンドを送信することができます。以下のコマンドの多くを発行した後、あなたは、Firefox OSの応答が表示されるはずです。Pythonのコンソールでは、必要なコードを含むMarionetteライブラリをインポートするために、次のコマンドを入力します:</p> - -<pre class="brush: bash">from marionette import Marionette</pre> - -<p>今、Marionetteがクライアントからのコマンドを受信する準備をするような、Marionetteセッションを開始するよう、次の2行を実行してください。:</p> - -<pre class="brush: bash">marionette = Marionette() -marionette.start_session()</pre> - -<p>上述したように、ロック画面を無効にしなかった場合は、このコマンドを使用して、プログラムで画面のロックを解除できます:</p> - -<pre class="brush: bash">marionette.execute_script('window.wrappedJSObject.lockScreen.unlock();')</pre> - -<h2 id="FirefoxのOS内部の別のフレームへのアクセス">FirefoxのOS内部の別のフレームへのアクセス</h2> - -<p>FirefoxのOSでのWebアプリは、色々なiFrameで動作します。別々のフレームにてWebアプリを実行すると、それらにセキュリティのための別個のコンテナと、(Windowのような)視覚管理も提供します。これはアプリが実行されるサンドボックスであるように考えることができます。Marionetteは、一度にフレームの1つで動作することができます。Marionetteを、対話をしようとしているフレームに切り替える必要があります。</p> - -<p>トップフレームはまた、System アプリです。すべてのアプリケーションとそれらのフレームは、System アプリの子です。新しいMarionette セッションはSystem のフレームで起動しますが、テストを開始するために、ホーム画面を見つけてそこに切り替える必要があります</p> - -<p>iFrameを見つけるために、何とかしてそれを識別する必要があります。Marionette がwebdriverのAPIに基づいているため、要素を見つけるために同じ戦略を使用していますので、webdriverがウェブ要素を識別するのに使用する戦略のいずれかを、簡単に使用することができます。<a href="http://www.w3.org/TR/webdriver/#element-location-strategies">element location strategies</a>で詳細をご覧ください。</p> - -<p>このケースでは、ホームスクリーンのiFrameを選択するために、CSSセレクタ<code>div.homescreen iframe</code> を使用します。<code>つまりfind_element()</code>関数は、その2番目の引数としてこれを取り、検索を実行するのにどの選択機構を使うかを決める第1引数を取ります。変数にこの結果を格納し、これを引数として<code>switch_to_frame()</code>関数を実行します。ここで、以下の2つのコマンドを試してみてください:</p> - -<pre class="brush: bash"># Switch context to the homescreen iframe and tap on the Contacts app icon -home_frame = marionette.find_element('css selector', 'div.homescreen iframe') -marionette.switch_to_frame(home_frame)</pre> - -<div class="note"> -<p><strong>注意</strong>: さらに読んでおくのや、フレーム切り替えを説明する図は, <a href="https://blog.mozilla.org/webqa/2013/02/13/part-2-ui-testing-on-firefox-os-working-with-iframes/">Working with iFrames</a>をご覧ください。</p> -</div> - -<h2 id="アプリケーションの開始">アプリケーションの開始</h2> - -<p>OKです。今、アイコンを確認できるホームスクリーンアプリにいて、<code>tap()</code>関数と<code>find_element()</code>関数をの組み合わせて使用し、そのアイコンをタップすることができます。</p> - -<pre class="brush: bash"><code>contacts_icon = marionette.find_element('xpath', "</code><code>//div[@class='icon']//span[contains(text(),'Contacts')]")</code> -contacts_icon.tap()</pre> - -<p>すべてがうまく行っている場合、ここで連絡先アプリを開いて見えるようにする必要がありますが、前にホームスクリーンで行ったように、対話するためには、まだ連絡先アプリのフレームに切り替える必要があります。:</p> - -<pre class="brush: bash"># First, we need to switch context back to the System frame -marionette.switch_to_frame() - -# Now, switch context to the contacts app frame -contacts_frame = marionette.find_element('css selector', "iframe[data-url*='contacts']") -marionette.switch_to_frame(contacts_frame)</pre> - -<p>フレーム切り替えは<code>True</code>を返すべきです。これができた場合、素晴らしい。これは連絡先アプリのコンテキスト内に入っていて、これを使用し始める準備ができていることを意味します。</p> - -<h2 id="アプリを操作する">アプリを操作する</h2> - -<p>次のステップでは、典型的なテストのタスクを実行します — 、新しい連絡先を作成し、それに名前を入力し、それを保存します。最初に、追加の連絡先ボタンをタップします:</p> - -<pre class="brush: bash"># Tap [+] to add a new Contact -marionette.find_element('id', 'add-contact-button').tap()</pre> - -<p>今度は、次の2つのコマンドを使用して連絡先の名前を追加してみましょう(<code>send_keys()</code>は要素に値を挿入するために使用されます):</p> - -<pre class="brush: bash">marionette.find_element('id', 'givenName').send_keys('Foo') -# Add the contact's surname -marionette.find_element('id', 'familyName').send_keys('Bar')</pre> - -<p>今、連絡先を保存するために<em>Done</em>ボタンをタップしましょう:</p> - -<pre class="brush: bash"><code class="language-html">marionette.find_element('id', 'save-button').tap()</code></pre> - -<p>今、連絡先アプリの内部に入力した新しい連絡先が表示されます。そうなっていれば、素晴らしいです!</p> - -<div class="note"> -<p><strong>注意</strong>: そうなっていない場合、連絡先アプリをリセットか停止して、Firefox OSでホームスクリーンの裏にナビゲートし、タスクを再実行してみてください。</p> -</div> - -<h2 id="Marionetteセッションを閉じます">Marionetteセッションを閉じます</h2> - -<p>最後に、次のコマンドを発行して、Marionetteセッションを終了する必要があります:</p> - -<pre class="brush: bash">marionette.delete_session()</pre> - -<p>これはかなりうまくいきましたが、テストを実行しようとするたびにPythonのコンソールに入力を始めることはできません。第3部では、テストを実行するたびに再利用できるように、Pythonのファイル内にこのスクリプトをコンパイルします。我々はテストに合格したか失敗したかを区別できるように、アサーションも追加します。</p> - -<div class="note"> -<p><strong>注意</strong>: Marionetteコマンドを記述する場合、必要となるロケータを把握するには、アプリの基本的なHTML構造にアクセスすることが極めて重要であるということが、確実にわかるでしょう。<a href="https://developer.mozilla.org/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_7_Writing_your_own_tests#Resources">Part 7: Writing your own tests</a>では、これについて役立つ有用なリソースを提供しています。</p> -</div> - -<p> </p> diff --git a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_3_reusable_tests/index.html b/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_3_reusable_tests/index.html deleted file mode 100644 index 18a417120a..0000000000 --- a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_3_reusable_tests/index.html +++ /dev/null @@ -1,183 +0,0 @@ ---- -title: 'パート 3: コードを再利用可能テストに更新する' -slug: Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_3_Reusable_tests -translation_of: Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_3_Reusable_tests ---- -<p></p><section class="Quick_links" id="Quick_Links"> - -<ol> - <li class="toggle"> - <details> - <summary>Build and install</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS">Build and install overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_build_process_summary">B2G OS build process summary</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/B2G_OS_build_prerequisites">Build prerequisites</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Preparing_for_your_first_B2G_build">Preparing for your first build</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building">Building B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_installer_add-on">B2G installer add-on</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Building_for_Flame_on_OS_X">Building B2G OS for Flame on Mac OS X</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Choosing_how_to_run_Gaia_or_B2G">Choosing how to run Gaia or B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Compatible_Devices">Compatible Devices</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Installing_on_a_mobile_device">Installing B2G OS on a mobile device</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_update_packages">Creating and applying B2G OS update packages</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building/FOTA_community_builds">Building and installing FOTA community builds</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_Build_Variables_Reference_Sheet">B2G build variables reference sheet</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Porting B2G OS</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS">Porting overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/basics">Porting basics</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/Porting_on_CyanogenMod">Porting on CyanogenMod</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Developing Gaia</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia">Developing Gaia overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Running_the_Gaia_codebase">Running the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Mulet">Run Gaia on desktop using Mulet</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Understanding_the_Gaia_codebase">Understanding the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Making_Gaia_code_changes">Making Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Testing_Gaia_code_changes">Testing Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Submitting_a_Gaia_patch">Submitting a Gaia patch</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Build_System_Primer">Gaia build system primer</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Different_ways_to_run_Gaia">Different ways to run Gaia</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/make_options_reference">Make options reference</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Gaia_tools_reference">Gaia tools reference</a></li> - </ol> - </details> - </li> - <li><a href="/ja/docs/Mozilla/B2G_OS/API">B2G OS APIs</a></li> -</ol> -</section><p></p> - -<p></p><div class="prevnext" style="text-align: right;"> - <p><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_2_Marionette_Firefox_OS_interactions" style="float: left;">« 前のページ</a><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_4_Reusing_commands_Firefox_OS_setup">次のページ »</a></p> -</div><p></p> - -<div class="summary"> -<p><span class="seoSummary">パート2では、Marionetteのクライアントコマンドを使用するとFirefox OSの制御が簡単にできることを学びましたが、Pythonのコンソールにそれらを入力するのは、遅くて退屈です。テスト自動化の重要な利点は、それが自律的に実行できることです。すべてのコードをPythonのファイルにコマンドを置き、次に一度にすべてを実行することができるように、このパートでそれを行う方法を学習します。</span></p> -</div> - -<h2 id="テストケースの要約">テストケースの要約</h2> - -<p>連絡先アプリを開き、新しい連絡先を追加する - パート2では、こんな典型的なテストケースを実行する手順をたどってきました:</p> - -<ol> - <li>Firefox OSのロックを解除 (オプション; 第2部では、手動でロック画面をオフにしました。それゆえ、以下のコードでこれを含みません。)</li> - <li>連絡先アプリに切り替え</li> - <li>新しい連絡先の追加アイコンをタップします</li> - <li>連絡先の名前を入力</li> - <li>タップして完了</li> - <li>しばらく待って、連絡先が存在していることを確認します</li> -</ol> - -<h2 id="Pythonのファイルに我々のテストを置きます">Pythonのファイルに我々のテストを置きます</h2> - -<p>Pythonのファイルにこれらのステップをすべて入れた場合、それを再利用し、はるかに素早く実行できます。あなたに都合の良いディレクトリを選んで、そこに <code>test_add_contact.py </code>と呼ばれる新しいテキストファイルを作成します。</p> - -<p>以下に示すように、このファイルにパート2で見たコマンドを入力します。良い習慣であるため、Pythonのクラス構造を使用し、チュートリアルの今後のステップでの良い基盤を作ります。</p> - -<pre class="brush: python">import time -from marionette import Marionette - -class TestContacts: - - def __init__(self): - self.test_add_contacts() - - def test_add_contacts(self): - # Create the client for this session. Assuming you're using the default port on a Marionette instance running locally - self.marionette = Marionette() - self.marionette.start_session() - - # Switch context to the homescreen iframe and tap on the contacts icon - time.sleep(2) - home_frame = self.marionette.find_element('css selector', 'div.homescreen iframe') - self.marionette.switch_to_frame(home_frame) - contacts_icon = self.marionette.find_element('xpath', "//div[@class='icon']//span[contains(text(),'Contacts')]") - contacts_icon.tap() - - # Switch context back to the base frame - self.marionette.switch_to_frame() - time.sleep(2) - - # Switch context to the contacts app - contacts_frame = self.marionette.find_element('css selector', "iframe[data-url*='contacts']") - self.marionette.switch_to_frame(contacts_frame) - - # Tap [+] to add a new Contact - self.marionette.find_element('id', 'add-contact-button').tap() - time.sleep(2) - - # Type name into the fields - self.marionette.find_element('id', 'givenName').send_keys('John') - self.marionette.find_element('id', 'familyName').send_keys('Doe') - - # Tap done - self.marionette.find_element('id', 'save-button').tap() - time.sleep(2) - - # Close the Marionette session now that the test is finished - self.marionette.delete_session() - -if __name__ == '__main__': - TestContacts() -</pre> - -<div class="note"> -<p><strong>注意</strong>: コード内で、パート2でカバーしていないと気づく1つの追加事項は、Python <code>time.sleep()</code>関数です— これは、次の行に継続する前に、一定時間スクリプトを停止します (秒単位で定義) 。ユーザが手動でボタンをタップすることなどや、FirefoxのOSが結果のアクションを完了するのを待つことをシミュレートする必要があるため、自動テストにこれらの行を追加しました。遅延なしにこのスクリプトを実行した場合は、 Pythonはすべてを瞬時に完了し、Firefox OSが追いつくことができないために、おそらくテストは失敗となるだろう。</p> -</div> - -<p>今、ターミナルでテストが保存されているディレクトリに移動し、次のコマンドを実行して、テストを実行することができます:</p> - -<pre class="brush: bash">python test_add_contact.py</pre> - -<div class="note"> -<p><strong>注意</strong>: Pythonのインデントルールに注意してください。 コピーして貼り付けた後は、コードを実行するためにすべてを正しくインデントする必要があるかもしれません。これに関連するエラーが発生した場合は、すべてのインデントレベルはタブで区切られていることを確認します。</p> -</div> - -<div class="note"> -<p><strong>注意</strong>: また、上記のコードを使用して挿入された名前はは"John Doe"であることがわかります。パート2での"Foo Bar"という名前と違います。コードが正常に実行し、別の連絡先を追加するように、我々はこうしました。 同じ名前の連絡先を追加しようとする場合、Firefox OSでは重複する連絡先についての警告が表示されます。現時点では、テストの実行を繰り返す最善の方法は、FirefoxのOSのインターフェースに入り、毎回実行する前に、手動で連絡先を削除することです。</p> -</div> - -<h2 id="アサーションを追加する">アサーションを追加する</h2> - -<p>自動テストに重要となり、我々のテストにまだ欠落している一点は、アサーションです — Firefox OSが望む状態に達しているかどうか (つまりテストが成功したかどうか)、というレポートまたは指標となるもの。新しい連絡先がアプリ内に存在するかどうかを確認するためにいくつかのコードを追加することでこれをやります。<br> - <br> - <code># Close the Marionette session...</code>行の直前に、このコードに追加し、クラスの他の行と同じレベルにインデントされていることを確認します:</p> - -<pre class="brush: python"># Now let's find the contact item and get its text -contact_name = self.marionette.find_element('css selector', 'li.contact-item:not([data-group$="ice"]) p').text -assert contact_name == 'John Doe'</pre> - -<p>古い連絡先を削除し、次のようにテストを再実行してみてください:</p> - -<pre class="brush: bash">python test_add_contact.py</pre> - -<p>全てがうまく実行できらた素晴らしい、今度は機能テストがあります!</p> - -<div class="note"> -<p><strong>注意</strong>: アサーションが失敗した場合は、以前の'Foo Bar'の連絡先はもう存在していないことを確認してください。アサートの前にCSSセレクタは、実際には、リスト内の最初の連絡先を拾っています。(アサートを呼ぶ前に<code> print "Contact name: %s" % contact_name</code> と呼ぶことで、見ることができます。).</p> -</div> - -<div class="note"> -<p><strong>注意</strong>: アサーションは現在何もしないように見えますが、<a href="/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_5_Introducing_a_test_runner">Part 5: Introducing a test runner</a>で紹介されているように、テストランナーを使用し始めるときアサーションはとても重要です。unittestのようなテストランナーは、アサーションを使ってテストが正常か完了したかどうかを確認し、次にこれらのテストの結果 (OK or FAIL)を返します。</p> -</div> - -<h2 id="タイミングに関する注意">タイミングに関する注意</h2> - -<p>自動テストを書く時に、対処するのが最も困難なことの一つは、タイミングです。Firefox OSが最後の一つを完了する前に、テストが次のステップに移行するなら、失敗を得る可能性が高いです。<br> - <br> - 上述したように、サンプルコードではこの問題を解決するために<code>time.sleep(x)</code>コマンドを追加しました。しかしながら、<code>time.sleep(x)</code>を使用することは良い方法ではありません。ハードコードされた設定時間を使用すると、テスト実行に長すぎたり、長さが足りなかったりする可能性があります。後者は最悪のケースであります; それは、偽陰性のテスト結果 (実際にアプリは完全に機能するが、テストが期待するより少し遅く振る舞う時に、失敗とレポートされるテストの意味) を生じます。</p> - -<p>次のパートでは、テストの特定部分を抽象化して、独立したPythonの関数にするよう進行します。そして、<code>sleep() </code>関数を、適切な動的待機で置き換えます。</p> - -<div id="divLookup" style="background-color: transparent; color: #000000; position: absolute; top: 3277px; left: 463px; padding: 0px; border-radius: 2px;"><img></div> diff --git a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_4_reusing_commands_firefox_os_setup/index.html b/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_4_reusing_commands_firefox_os_setup/index.html deleted file mode 100644 index 36d6e22400..0000000000 --- a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_4_reusing_commands_firefox_os_setup/index.html +++ /dev/null @@ -1,160 +0,0 @@ ---- -title: 'パート 4: Firefox OS をセットアップする再利用コマンド' -slug: >- - Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_4_Reusing_commands_Firefox_OS_setup -tags: - - Automation - - Firefox OS - - Gaia - - Python - - Testing - - gaia-ui-tests -translation_of: >- - Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_4_Reusing_commands_Firefox_OS_setup ---- -<p></p><section class="Quick_links" id="Quick_Links"> - -<ol> - <li class="toggle"> - <details> - <summary>Build and install</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS">Build and install overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_build_process_summary">B2G OS build process summary</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/B2G_OS_build_prerequisites">Build prerequisites</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Preparing_for_your_first_B2G_build">Preparing for your first build</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building">Building B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_installer_add-on">B2G installer add-on</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Building_for_Flame_on_OS_X">Building B2G OS for Flame on Mac OS X</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Choosing_how_to_run_Gaia_or_B2G">Choosing how to run Gaia or B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Compatible_Devices">Compatible Devices</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Installing_on_a_mobile_device">Installing B2G OS on a mobile device</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_update_packages">Creating and applying B2G OS update packages</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building/FOTA_community_builds">Building and installing FOTA community builds</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_Build_Variables_Reference_Sheet">B2G build variables reference sheet</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Porting B2G OS</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS">Porting overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/basics">Porting basics</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/Porting_on_CyanogenMod">Porting on CyanogenMod</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Developing Gaia</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia">Developing Gaia overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Running_the_Gaia_codebase">Running the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Mulet">Run Gaia on desktop using Mulet</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Understanding_the_Gaia_codebase">Understanding the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Making_Gaia_code_changes">Making Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Testing_Gaia_code_changes">Testing Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Submitting_a_Gaia_patch">Submitting a Gaia patch</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Build_System_Primer">Gaia build system primer</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Different_ways_to_run_Gaia">Different ways to run Gaia</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/make_options_reference">Make options reference</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Gaia_tools_reference">Gaia tools reference</a></li> - </ol> - </details> - </li> - <li><a href="/ja/docs/Mozilla/B2G_OS/API">B2G OS APIs</a></li> -</ol> -</section><p></p> - -<p></p><div class="prevnext" style="text-align: right;"> - <p><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_3_Reusable_tests" style="float: left;">« 前のページ</a><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_5_Introducing_a_test_runner">次のページ »</a></p> -</div><p></p> - -<div class="summary"> -<p><span class="seoSummary">パート2とパート3では、動作するテストを理解しました。しかし、テストを実行する前にその状態をリセットしたい場合(例えば、開いているアプリケーションを停止する)、これを手動で行う必要があったでしょう。それは少し退屈なので、再び自動化する必要があります!この部分では、再利用できる独立したPythonのメソッドに少しのコードを発生せることによって、もっと自動化する方法を見ていきます。</span></p> -</div> - -<h2 id="自動的に状態をリセット">自動的に状態をリセット</h2> - -<p>典型的なテストの実行開始時に、おそらくFirefox OSのロック画面を解除し、すべての実行中のアプリケーションを強制終了することを望みます。それでは、これを行う方法を見てみましょう。</p> - -<h3 id="ロック画面の解除">ロック画面の解除</h3> - -<p>先に進む前に、まだ行っていない場合 <em>Settings App > Screen lock > Lock screen</em> で再びロック画面を有効にします。</p> - -<p>ちょうどクラス内の場所で、あなたの <code>test_add_contact.py</code> ファイルに次のPythonのメソッドを追加します。:</p> - -<pre class="brush: python">def unlock_screen(self): - self.marionette.execute_script('window.wrappedJSObject.lockScreen.unlock();')</pre> - -<p>呼び出された時、このメソッドは現在のFirefox OSのロックを解除します。 今度は <code>self.marionette.start_session()</code> 行の下に、下記の行を追加することで、テスト内でこれを呼びましょう。:</p> - -<pre class="brush: python"># Unlock the screen -self.unlock_screen()</pre> - -<h3 id="開いているすべてのアプリケーションの停止">開いているすべてのアプリケーションの停止</h3> - -<p>今、実行時に開いているすべてのアプリケーションを停止するために、私たちのコードにメソッドを追加します。これは下記のように見えます。:</p> - -<pre class="brush: python"> def kill_all(self): - self.marionette.switch_to_frame() - self.marionette.execute_async_script(""" - // Kills all running apps, except the homescreen. - function killAll() { - let manager = window.wrappedJSObject.appWindowManager; - - let apps = manager.getApps(); - for (let id in apps) { - let origin = apps[id].origin; - if (origin.indexOf('verticalhome') == -1) { - manager.kill(origin); - } - } - }; - killAll(); - // return true so execute_async_script knows the script is complete - marionetteScriptFinished(true); - """)</pre> - -<p>直前のセクションで追加した <code>unlock_screen</code> メソッドの直後にこれを追加します。</p> - -<p>次に、テストの残りの部分と一緒にこれを実行するには、下記を追加します。つまり <code>self.unlock_screen()</code> 行の直後に追加します。:</p> - -<pre class="brush: python"># kill all open apps -self.kill_all()</pre> - -<p>今、最後にテスト実行した後に連絡先アプリを開いたままにしておき、また再度テストを実行しようとする前にロック画面に戻してみてください。画面のロックが解除されることに加えて、テストが再実行される前に、開いている連絡先アプリが自動的に停止されます。だから、その状態は、今実行しているテストには影響しません。これは、テスト実行の長期間の信頼性のために重要です。</p> - -<p>再び数回テストを実行し、すべて動作するのとFirefox OSが正しくリセットされているかどうかを確認します。</p> - -<h2 id="ダイナミックウェイト">ダイナミックウェイト</h2> - -<p>パート3ではダイナミックウェイトの重要性を述べました。Marionetteには下記のような一般的な構文を使用した、WebDriver/Selenium2のようなウェイトがあります。:</p> - -<pre class="brush: python">from marionette_driver import Wait - -# Wait until element is displayed -Wait(self.marionette).until(lambda m: m.find_element('id', 'element_id').is_displayed())</pre> - -<p>指定された要素が表示されるまで、このコードはウェイトします。この時点で、対話する準備が整ったと分かります。テストでこのコード構成を使用してみましょう。</p> - -<p>まず第一に、既存のインポート行の直後に、ウェイトインポート行を含めます:</p> - -<pre class="brush: python">from marionette_driver import Wait</pre> - -<p>今、コンタクトフレームが表示されるまで待機する <code>Wait()</code> メソッドで、連絡先アイコンをタップした後の2つ目の <code>time.sleep(2)</code> 関数(<code>self.marionette.switch_to_frame()</code> 行の直後)を、置き換えることができます。:</p> - -<pre class="brush: python">Wait(self.marionette).until(lambda m: m.find_element('css selector', "iframe[data-url*='contacts']").is_displayed())</pre> - -<p>新しい連絡先の作成を開始する + 記号をタップするとき、<em>Add contact</em> フォームが完全に表示されるまでスライドされるのを待ちたいです。<em>Done</em> (保存) ボタンは次にタップが必要となるもので、このため、継続する前に所定の位置にスライドされるのを待つでしょう。3つ目の <code>time.sleep(2)</code> 関数を、次の行で置き換えます。:</p> - -<pre class="brush: python">Wait(self.marionette).until(lambda m: m.find_element('id', 'save-button').location['y']== 0)</pre> - -<p>この例では、<em>Done</em> ボタンが画面の上部に到達するのを待ちます。アニメーション化されたときに、要素は複数のポイントに表示されます。しかし、その最終的な静止位置は、待つための最も安全なものです。</p> - -<p>また、要素が表示され"ない"のを待つこともできます。<em>Done</em>をタップした後で、残りのコードを実行する前に、同様な <code>Wait()</code> メソッドにnotをつけて使用し、<em>Done</em>ボタンが隠されるのを待ちます。4つ目と最終の <code>time.sleep(2)</code> 関数を、下記で置換します。:</p> - -<pre class="brush: python">Wait(self.marionette).until(lambda m: not m.find_element('id', 'save-button').is_displayed())</pre> - -<p>テストがOKに動作している場合には、素晴らしいです!テストのモジュール性と信頼性を向上させました。パート5では、テストを実行するためのテストランナーの使い方ご紹介します。</p> diff --git a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_5_introducing_a_test_runner/index.html b/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_5_introducing_a_test_runner/index.html deleted file mode 100644 index 4ce156330b..0000000000 --- a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_5_introducing_a_test_runner/index.html +++ /dev/null @@ -1,243 +0,0 @@ ---- -title: 'パート 5: テストランナーを導入する' -slug: >- - Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_5_Introducing_a_test_runner -tags: - - Automation - - Firefox OS - - Gaia - - Python - - gaia-ui-tests - - tests -translation_of: >- - Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_5_Introducing_a_test_runner ---- -<p></p><section class="Quick_links" id="Quick_Links"> - -<ol> - <li class="toggle"> - <details> - <summary>Build and install</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS">Build and install overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_build_process_summary">B2G OS build process summary</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/B2G_OS_build_prerequisites">Build prerequisites</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Preparing_for_your_first_B2G_build">Preparing for your first build</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building">Building B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_installer_add-on">B2G installer add-on</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Building_for_Flame_on_OS_X">Building B2G OS for Flame on Mac OS X</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Choosing_how_to_run_Gaia_or_B2G">Choosing how to run Gaia or B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Compatible_Devices">Compatible Devices</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Installing_on_a_mobile_device">Installing B2G OS on a mobile device</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_update_packages">Creating and applying B2G OS update packages</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building/FOTA_community_builds">Building and installing FOTA community builds</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_Build_Variables_Reference_Sheet">B2G build variables reference sheet</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Porting B2G OS</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS">Porting overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/basics">Porting basics</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/Porting_on_CyanogenMod">Porting on CyanogenMod</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Developing Gaia</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia">Developing Gaia overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Running_the_Gaia_codebase">Running the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Mulet">Run Gaia on desktop using Mulet</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Understanding_the_Gaia_codebase">Understanding the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Making_Gaia_code_changes">Making Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Testing_Gaia_code_changes">Testing Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Submitting_a_Gaia_patch">Submitting a Gaia patch</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Build_System_Primer">Gaia build system primer</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Different_ways_to_run_Gaia">Different ways to run Gaia</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/make_options_reference">Make options reference</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Gaia_tools_reference">Gaia tools reference</a></li> - </ol> - </details> - </li> - <li><a href="/ja/docs/Mozilla/B2G_OS/API">B2G OS APIs</a></li> -</ol> -</section><p></p> - -<p></p><div class="prevnext" style="text-align: right;"> - <p><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_4_Reusing_commands_Firefox_OS_setup" style="float: left;">« 前のページ</a><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_6_Marionette_By_class">次のページ »</a></p> -</div><p></p> - -<div class="summary"> -<p><span class="seoSummary">すべては、ここまでうまく進んでいます。しかし、まだ1つのテストのみを扱っています。実世界の大きなWebアプリケーションをテストする時には、数十または数百のテストケースである場合があり、それぞれを手動で実行することは絶対にしたくありません。このようなシナリオでは、我々は私たちのためにテストを見つけて実行するテストランナーを使用する必要があります。この記事ではただそれだけについて見ていきます。</span></p> -</div> - -<h2 id="テストランナー">テストランナー</h2> - -<p>テストランナーは、実際のテストフレームワークのための良好な基礎を提供します。テストランナーがテスト、属性を含むタグのテスト (アノテーション)を実行するように設計されて、レポートおよび他の機能を提供します。利用可能な多くのPythonのテストランナーがあります。しかし、この場合、効果的なシンプルで、PythonでパッケージされているようにPythonの独自の <strong>unittest</strong> を使います。</p> - -<p>一般的には3つの標準のセクションにテストを分割します。テストランナーのセットアップのための典型的な<code>setUp()</code>、tests、<code>tearDown()</code><br> - <br> - <code>setUp()</code> と <code>tearDown()</code> メソッドはすべてのテストのために自動的に実行されて、それぞれ下記を含んでいます:</p> - -<ul> - <li>画面ロックを解除し開いているアプリケーションを停止するといった、テストを実行する前に必要なセットアップの手順。</li> - <li>Marionetteセッションを閉じるといった、テスト後に実行に必要なクールダウンの手順。</li> -</ul> - -<p>セットアップのテスト部分では、実際のテストのために実行したい任意のコードです。第2-4部分の上に構築されたテストにこれを適用する方法を見てみましょう。</p> - -<h2 id="ユニットテストとtest_add_contact.pyの実行">ユニットテストとtest_add_contact.pyの実行</h2> - -<p>最初のインポートのユニットテストに必要なユニットテストを使用するには、他のインポート行の下に次を追加してください。:</p> - -<pre class="brush: python">import unittest</pre> - -<p>次に、テストランナーを作成する必要があります。これを行うために、 <code>unittest.Testcase</code> クラスから <code>TestContacts</code> クラス継承を行います。つまり、<code>class</code> 行を下記に更新してください。:</p> - -<pre class="brush: python">class TestContacts(unittest.TestCase):</pre> - -<p>また、次のものを削除する必要があります:</p> - -<pre class="brush: python"> def __init__(self): - self.test_add_contacts()</pre> - -<p>テストを初期化すると、代わりにユニットテストによって処理されますので、自分自身を処理する必要はありません。あなたのコードの下で、次のものを置き換えて:</p> - -<pre class="brush: python">if __name__ == '__main__': - TestContacts()</pre> - -<p>下記を用います。:</p> - -<pre class="brush: python">if __name__ == '__main__': - unittest.main()</pre> - -<p>次に、<code>TestContacts</code> クラス内部に <code>setUp(self):</code> メソッドを生成する必要があります。そして、次の手順を実施します。:</p> - -<ol> - <li>Marionetteをインスタンス化し、Marionetteセッションを開始します</li> - <li>画面ロックを解除します</li> - <li>開いているすべてのアプリケーションを強制終了します</li> - <li>連絡先アプリをロードします</li> -</ol> - -<p>このメソッドは、以下のようになります。<code>test_add_contacts</code> で既にある同一の行を削除する必要があります。</p> - -<pre class="brush: python"> def setUp(self): - # Create the client for this session. Assuming you're using the default port on a Marionette instance running locally - self.marionette = Marionette() - self.marionette.start_session() - - # Unlock the screen - self.unlock_screen() - - # kill all open apps - self.kill_all() - - # Switch context to the homescreen iframe - time.sleep(2) - home_frame = self.marionette.find_element('css selector', 'div.homescreen iframe') - self.marionette.switch_to_frame(home_frame)</pre> - -<p>今の<code>tearDown(self):</code>メソッドを作成します。ここにMarionetteセッションを閉じるためのコードを追加する必要があります。メソッドは次のようになります。:</p> - -<pre class="brush: python"> def tearDown(self): - # Close the Marionette session now that the test is finished - self.marionette.delete_session() -</pre> - -<p>ここでも、<code>test_add_contacts</code> から同じ行を削除することを忘れないでください。</p> - -<p>今、前にしたとおりにテストを実行してみてください。これで、パスと失敗のレポートを取得することを確認できます。これは、ユニットテストやpy.testなどのテストランナーを使用する利点の一つです。</p> - -<div class="note"> -<p><strong>注意</strong>: あなたが動けなくなる場合は、インターネットのまわりのユニットテスト使用するガイドがたくさんあります。<a href="http://selenium-python.readthedocs.org/en/latest/getting-started.html">http://selenium-python.readthedocs.org/en/latest/getting-started.html</a> と <a href="http://assertselenium.com/2013/10/07/getting-started-with-python-webdriver/">http://assertselenium.com/2013/10/07/getting-started-with-python-webdriver/</a> をお勧めします。Pythonとwebdriverをするためのものであるが、これらはまだ関連しています。</p> -</div> - -<h2 id="参照コード">参照コード</h2> - -<p>参考のため、この段階での私たちの最終的なコードは次のようになります:</p> - -<pre class="brush: python">import time -from marionette import Marionette -from marionette_driver import Wait -import unittest - - -class TestContacts(unittest.TestCase): - - def unlock_screen(self): - self.marionette.execute_script('window.wrappedJSObject.lockScreen.unlock();') - - def kill_all(self): - self.marionette.switch_to_frame() - self.marionette.execute_async_script(""" - // Kills all running apps, except the homescreen. - function killAll() { - let manager = window.wrappedJSObject.AppWindowManager; - - let apps = manager.getApps(); - for (let id in apps) { - let origin = apps[id].origin; - if (origin.indexOf('verticalhome') == -1) { - manager.kill(origin); - } - } - }; - killAll(); - // return true so execute_async_script knows the script is complete - marionetteScriptFinished(true); - """) - - def setUp(self): - # Create the client for this session. Assuming you're using the default port on a Marionette instance running locally - self.marionette = Marionette() - self.marionette.start_session() - - # Unlock the screen - self.unlock_screen() - - # kill all open apps - self.kill_all() - - # Switch context to the homescreen iframe and tap on the contacts icon - time.sleep(2) - home_frame = self.marionette.find_element('css selector', 'div.homescreen iframe') - self.marionette.switch_to_frame(home_frame) - - - def test_add_contacts(self): - <code>contacts_icon = self.marionette.find_element('xpath', "</code><code>//div[@class='icon']//span[contains(text(),'Contacts')]")</code> - contacts_icon.tap() - - # Switch context back to the base frame - self.marionette.switch_to_frame() - Wait(self.marionette).until(lambda m: m.find_element('css selector', "iframe[data-url*='contacts']").is_displayed()) - - # Switch context to the contacts app - contacts_frame = self.marionette.find_element('css selector', "iframe[data-url*='contacts']") - self.marionette.switch_to_frame(contacts_frame) - - # Tap [+] to add a new Contact - self.marionette.find_element('id', 'add-contact-button').tap() - Wait(self.marionette).until(lambda m: m.find_element('id', 'save-button').location['y']== 0) - - # Type name into the fields - self.marionette.find_element('id', 'givenName').send_keys('John') - self.marionette.find_element('id', 'familyName').send_keys('Doe') - - # Tap done - self.marionette.find_element('id', 'save-button').tap() - Wait(self.marionette).until(lambda m: not m.find_element('id', 'save-button').is_displayed()) - - def tearDown(self): - # Close the Marionette session now that the test is finished - self.marionette.delete_session() - -if __name__ == '__main__': - unittest.main() - -</pre> diff --git a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_6_marionette_by_class/index.html b/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_6_marionette_by_class/index.html deleted file mode 100644 index 32b7aa2bfd..0000000000 --- a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_6_marionette_by_class/index.html +++ /dev/null @@ -1,132 +0,0 @@ ---- -title: 'パート 6: クラスによって、タプルと Marionette を使う' -slug: Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_6_Marionette_By_class -tags: - - Automation - - Firefox OS - - Gaia - - Python - - Testing - - gaia-ui-tests -translation_of: Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_6_Marionette_By_class ---- -<p></p><section class="Quick_links" id="Quick_Links"> - -<ol> - <li class="toggle"> - <details> - <summary>Build and install</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS">Build and install overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_build_process_summary">B2G OS build process summary</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/B2G_OS_build_prerequisites">Build prerequisites</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Preparing_for_your_first_B2G_build">Preparing for your first build</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building">Building B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_installer_add-on">B2G installer add-on</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Building_for_Flame_on_OS_X">Building B2G OS for Flame on Mac OS X</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Choosing_how_to_run_Gaia_or_B2G">Choosing how to run Gaia or B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Compatible_Devices">Compatible Devices</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Installing_on_a_mobile_device">Installing B2G OS on a mobile device</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_update_packages">Creating and applying B2G OS update packages</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building/FOTA_community_builds">Building and installing FOTA community builds</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_Build_Variables_Reference_Sheet">B2G build variables reference sheet</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Porting B2G OS</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS">Porting overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/basics">Porting basics</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/Porting_on_CyanogenMod">Porting on CyanogenMod</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Developing Gaia</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia">Developing Gaia overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Running_the_Gaia_codebase">Running the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Mulet">Run Gaia on desktop using Mulet</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Understanding_the_Gaia_codebase">Understanding the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Making_Gaia_code_changes">Making Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Testing_Gaia_code_changes">Testing Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Submitting_a_Gaia_patch">Submitting a Gaia patch</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Build_System_Primer">Gaia build system primer</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Different_ways_to_run_Gaia">Different ways to run Gaia</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/make_options_reference">Make options reference</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Gaia_tools_reference">Gaia tools reference</a></li> - </ol> - </details> - </li> - <li><a href="/ja/docs/Mozilla/B2G_OS/API">B2G OS APIs</a></li> -</ol> -</section><p></p> - -<p></p><div class="prevnext" style="text-align: right;"> - <p><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_5_Introducing_a_test_runner" style="float: left;">« 前のページ</a><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_7_Writing_your_own_tests">次のページ »</a></p> -</div><p></p> - -<div class="summary"> -<p><span class="seoSummary">コードでは、これまで、特定の要素を見つけるために多くのロケータを使用しています。アプリケーション(iFrames)やアプリケーションの特定の部分であるかどうか。今まで、結果として、直接インラインロケータを書いて、コードを複製しています。さらに状況を改善するためには、再利用できるように、Pythonのタプル変数にこのロケータを抽象化することをお勧めします。この記事では、どのようにお見せしましょう。</span></p> -</div> - -<h2 id="タプル、およびクラスによるMarionette">タプル、およびクラスによるMarionette</h2> - -<p>例として、連絡先アプリiFrameを見つけるために使用しているロケータを考えてください。:</p> - -<pre class="brush: python">'css selector', "iframe[data-url*='contacts']"</pre> - -<p>表示されるようにフレームを待っているときと切り替えるときの両方でこのロケータを使用します。簡単に物事を行うために、変数でこれを保存することができます。(また<code>By</code>をインポートする必要があります。):</p> - -<pre class="brush: python">from marionette import By - -_contacts_frame_locator = (By.CSS_SELECTOR, "iframe[data-url*='contacts']")</pre> - -<p>Marionette <code>By</code> クラスは、<code>id</code>やCSSセレクタなどのように位置決め技術へのアクセスへのショートカットを提供します。前のように、セレクタを使用して要素を取得し、次にCSSのタプル変数に格納します。HTML(とロケータ)が変化した場合、2つの場所で変更を行うよりも、一度変数を更新する方が簡単です。このタプルを使用するには、そのような<code>find_element()</code>メソッドでそれを含みます。:</p> - -<pre class="brush: python">self.marionette.find_element(*self._contacts_frame_locator)</pre> - -<div class="note"> -<p><strong>注意</strong>: <code>*</code> — これに関連して — Pythonコードは、引数リストを開梱するためのものです; それは<code>find_element()</code>に渡る必要がある2つの引数に元のタプルを分割しています。詳細および例について、Pythonのドキュメントで<a href="http://docs.python.org/2/tutorial/controlflow.html#unpacking-argument-lists">Unpacking argument lists</a>をご覧ください。</p> -</div> - -<p>他のタプルの例、それは、<code>id</code> 属性によって探し出しますが、以下のとおりであります:</p> - -<pre class="brush: python">_add_contact_button_locator = (By.ID, 'add-contact-button')</pre> - -<h2 id="連絡先のテストでタプルとByを使用">連絡先のテストでタプルとByを使用</h2> - -<p>今では、テストのうち、ロケータを共有することができる <code>TestContacts</code> クラスのスコープにロケータを移動させることにより、<code>test_add_contact.py</code> のテストケースで重複を減らすための時間です。2,3のロケータを代入する方法を示し、その後、読者の演習として残りの部分を残しておきます。</p> - -<p>まず第一に、コードの先頭に次のように置くことによって、<code>By</code> をインポートすることを確認する必要があります。:</p> - -<pre class="brush: python">from marionette import By</pre> - -<p>今、<code>TestContacts</code>クラスの一番上にタプルを追加することができます。ちょうど<code>class TestContacts(unittest.TestCase):</code>行の下に次の行を追加します。:</p> - -<pre class="brush: python">_contacts_frame_locator = (By.CSS_SELECTOR, "iframe[data-url*='contacts']") -_save_button_locator = (By.ID, "save-button") -</pre> - -<p>今、コードを通過し、すべてのインスタンスを置き換えることができます</p> - -<pre class="brush: python">find_element('id', 'save-button')</pre> - -<p>with</p> - -<pre class="brush: python">find_element(*self._save_button_locator)</pre> - -<p>and all instances of</p> - -<pre class="brush: python">find_element('css selector', "iframe[data-url*='contacts']")</pre> - -<p>with</p> - -<pre class="brush: python">find_element(*self._contacts_frame_locator)</pre> - -<p>そして、それは今のところこれだけです。既にあってもこの単純な例では、このコードの再利用のメリットを確認できるようになることを確信しています。この手法では、同じロケータが5、10または20回使用することを有することができる、より複雑なテストを書くために開始するように、特に有効になり始めます。<br> - <br> - </p> diff --git a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_7_writing_your_own_tests/index.html b/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_7_writing_your_own_tests/index.html deleted file mode 100644 index d1d2a3551f..0000000000 --- a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_7_writing_your_own_tests/index.html +++ /dev/null @@ -1,122 +0,0 @@ ---- -title: 'パート 7: 自分自身のテストを書く' -slug: Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_7_Writing_your_own_tests -tags: - - Automation - - Firefox OS - - Gaia - - Python - - gaia-ui-tests - - tests -translation_of: Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_7_Writing_your_own_tests ---- -<p></p><section class="Quick_links" id="Quick_Links"> - -<ol> - <li class="toggle"> - <details> - <summary>Build and install</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS">Build and install overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_build_process_summary">B2G OS build process summary</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/B2G_OS_build_prerequisites">Build prerequisites</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Preparing_for_your_first_B2G_build">Preparing for your first build</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building">Building B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_installer_add-on">B2G installer add-on</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Building_for_Flame_on_OS_X">Building B2G OS for Flame on Mac OS X</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Choosing_how_to_run_Gaia_or_B2G">Choosing how to run Gaia or B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Compatible_Devices">Compatible Devices</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Installing_on_a_mobile_device">Installing B2G OS on a mobile device</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_update_packages">Creating and applying B2G OS update packages</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building/FOTA_community_builds">Building and installing FOTA community builds</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_Build_Variables_Reference_Sheet">B2G build variables reference sheet</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Porting B2G OS</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS">Porting overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/basics">Porting basics</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/Porting_on_CyanogenMod">Porting on CyanogenMod</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Developing Gaia</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia">Developing Gaia overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Running_the_Gaia_codebase">Running the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Mulet">Run Gaia on desktop using Mulet</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Understanding_the_Gaia_codebase">Understanding the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Making_Gaia_code_changes">Making Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Testing_Gaia_code_changes">Testing Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Submitting_a_Gaia_patch">Submitting a Gaia patch</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Build_System_Primer">Gaia build system primer</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Different_ways_to_run_Gaia">Different ways to run Gaia</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/make_options_reference">Make options reference</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Gaia_tools_reference">Gaia tools reference</a></li> - </ol> - </details> - </li> - <li><a href="/ja/docs/Mozilla/B2G_OS/API">B2G OS APIs</a></li> -</ol> -</section><p></p> - -<p></p><div class="prevnext" style="text-align: right;"> - <p><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_6_Marionette_By_class" style="float: left;">« 前のページ</a><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_8_Using_a_base_class">次のページ »</a></p> -</div><p></p> - -<div class="summary"> -<p><span class="seoSummary">これまでのところ、すばやく設定し、実行してフォローするのに十分な手順に沿って、FirefoxのOS上で、独自の自動テストを書き始めるために必要なツールや情報のほとんどを与えてくれました。この部分では、いくつかのリソースやアイデアをご提供し、人出がいらないつもりで、次に自身の方法を作るために奨励しています。ここでは、独自のテストを書くの方に移動を開始します - お楽しみください!</span></p> -</div> - -<h2 id="リソース">リソース</h2> - -<p>自身のユニットテストを構築するために開始するように次のリソースが有用であろう。</p> - -<ul> - <li><a href="/Firefox_OS/Using_the_App_Manager">Firefox OS App Manager</a>はデバイス上で、またはシミュレータでの直接Gaiaのデバッグをするための素晴らしいツールです。これは、アクセスして要素を操作するために使用するロケーターを見つけるために下にあるコードを検査するための良い方法です。</li> - <li>より限定されたが、より低いオーバーヘッド検査機構として、<code>print self.marionette.page_source</code> コマンドを使用して、コンソールへのHTMLソースをダンプすることができます。</li> - <li>別のオプションは、<a href="https://github.com/mozilla-b2g/gaia/tree/master/apps">Gaia Git repo</a>で生のHTMLを見ることです。</li> - <li>Marionetteのコマンドの詳細については、<a href="https://marionette_client.readthedocs.org/en/latest/">Marionette docs</a>をご覧ください。</li> -</ul> - -<h2 id="新規および変更されたテストのためのアイデア">新規および変更されたテストのためのアイデア</h2> - -<p>このセクションでは、始めるためにいくつかのアイデアを提供します。</p> - -<h3 id="test_add_contact.pyの変更">test_add_contact.pyの変更</h3> - -<p>すでに動作してきたテストを修正してみましょう:</p> - -<ol> - <li>テスト接点には一意の名前を毎回持っていることを確認します。</li> - <li><code>setUp()</code> ステップにおけるすべての連絡先を削除します。</li> - <li>ロック解除前に画面を復帰。</li> -</ol> - -<p>今度は、別のテストメソッドの追加しましょう。これは、それが名前の最初に<code>test_</code>を持っている限り好きなものを呼び出すことができます。このテストでは、次の操作を行う必要があります。:</p> - -<ol> - <li>オープンコンタクト。</li> - <li>最初のテストで作成されたものと異なる名前で連絡先を作成します。</li> - <li>編集モードで連絡先を再入力します。</li> - <li><em>Company</em>を追加します。</li> - <li><em>Done</em>をタップします。</li> - <li>会社が表示されていることを主張しています。</li> -</ol> - -<p>テストファイルを実行すると、今、両方のテストが実行されます。今、テスト自動化の強度に近づいています — 自動的に一連のテストを実行し、結果を報告する機能!</p> - -<h3 id="いくつかの新しいテストのアイデア">いくつかの新しいテストのアイデア</h3> - -<ul> - <li>連絡先を作成します。連絡先を編集し、名前を変更します。名前の変更が画面に反映されるべきです。</li> - <li>それが好きなようにそれを追加するためのコンタクトと 'star'を作成します。メイン画面には、* (スター) カテゴリの下に表示されているはずです。</li> - <li>電話番号と連絡先を作成します。連絡先のレコードを開いて、「メッセージ」アイコンをタップした後、メッセージアプリは、受信者フィールドに、連絡先で開く必要があります。</li> -</ul> - -<p> </p> diff --git a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_8_using_a_base_class/index.html b/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_8_using_a_base_class/index.html deleted file mode 100644 index af37d37b4e..0000000000 --- a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_8_using_a_base_class/index.html +++ /dev/null @@ -1,153 +0,0 @@ ---- -title: 'パート 8: ベースクラスを使用する' -slug: Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_8_Using_a_base_class -tags: - - Automation - - Firefox OS - - Gaia - - Python - - gaia-ui-tests - - tests -translation_of: Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_8_Using_a_base_class ---- -<p></p><section class="Quick_links" id="Quick_Links"> - -<ol> - <li class="toggle"> - <details> - <summary>Build and install</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS">Build and install overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_build_process_summary">B2G OS build process summary</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/B2G_OS_build_prerequisites">Build prerequisites</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Preparing_for_your_first_B2G_build">Preparing for your first build</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building">Building B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_installer_add-on">B2G installer add-on</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Building_for_Flame_on_OS_X">Building B2G OS for Flame on Mac OS X</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Choosing_how_to_run_Gaia_or_B2G">Choosing how to run Gaia or B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Compatible_Devices">Compatible Devices</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Installing_on_a_mobile_device">Installing B2G OS on a mobile device</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_update_packages">Creating and applying B2G OS update packages</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building/FOTA_community_builds">Building and installing FOTA community builds</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_Build_Variables_Reference_Sheet">B2G build variables reference sheet</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Porting B2G OS</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS">Porting overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/basics">Porting basics</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/Porting_on_CyanogenMod">Porting on CyanogenMod</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Developing Gaia</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia">Developing Gaia overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Running_the_Gaia_codebase">Running the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Mulet">Run Gaia on desktop using Mulet</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Understanding_the_Gaia_codebase">Understanding the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Making_Gaia_code_changes">Making Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Testing_Gaia_code_changes">Testing Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Submitting_a_Gaia_patch">Submitting a Gaia patch</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Build_System_Primer">Gaia build system primer</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Different_ways_to_run_Gaia">Different ways to run Gaia</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/make_options_reference">Make options reference</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Gaia_tools_reference">Gaia tools reference</a></li> - </ol> - </details> - </li> - <li><a href="/ja/docs/Mozilla/B2G_OS/API">B2G OS APIs</a></li> -</ol> -</section><p></p> - -<p></p><div class="prevnext" style="text-align: right;"> - <p><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_7_Writing_your_own_tests" style="float: left;">« 前のページ</a><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_9_app_objects">次のページ »</a></p> -</div><p></p> - -<div class="summary"> -<p><span class="seoSummary">今、おそらく、進捗状況についてのかなり良く感じている複数のテストを持っています。しかし、さらなるコード効率を向上させる他の方法があります — これまでに、各テストファイルにおいて <code>setUp()</code> と <code>tearDown()</code> メソッドが含まれるように持っていたことがあります。 このシリーズで見てきた現在のコンストラクトで行きます。数十のテストを持っている場合、それはコードの重複がたくさんです! この記事では、<code>TestBase</code> クラスのすべてのテストに共通な<code>setUp()</code>/<code>tearDown()</code> コードを配置する方法を見てみましょう。これは、各個々のテストファイルにインポートすることができます。</span></p> -</div> - -<h2 id="test_base.py">test_base.py</h2> - -<p>開始するには、既存のテストケースと同じディレクトリに <code>test_base.py</code> と呼ばれる新しいファイルを作成します。</p> - -<p>次に、<code>setUp()</code> と <code>tearDown()</code> メソッドを含む<code>TestBase</code> クラスに加えて、ファイルに共通の設定(<code>unittest</code>, <code>Marionette</code> and <code>time</code>)に関連するあなたの大切な書類を移動します。そして、共通ヘルパー関数(<code>unlock_screen()</code> のような)と関連付けられています。 ファイルには、次のようになります:</p> - -<pre class="brush: python">import time -import unittest -from marionette import Marionette - - -class TestBase(unittest.TestCase): - - def unlock_screen(self): - self.marionette.execute_script('window.wrappedJSObject.lockScreen.unlock();') - - def kill_all(self): - self.marionette.switch_to_frame() - self.marionette.execute_async_script(""" - // Kills all running apps, except the homescreen. - function killAll() { - let manager = window.wrappedJSObject.AppWindowManager; - - let apps = manager.getApps(); - for (let id in apps) { - let origin = apps[id].origin; - if (origin.indexOf('verticalhome') == -1) { - manager.kill(origin); - } - } - }; - killAll(); - // return true so execute_async_script knows the script is complete - marionetteScriptFinished(true); - """) - - def setUp(self): - # Create the client for this session. Assuming you're using the default port on a Marionette instance running locally - self.marionette = Marionette() - self.marionette.start_session() - - # Unlock the screen - self.unlock_screen() - - # kill all open apps - self.kill_all() - - # Switch context to the homescreen iframe and tap on the contacts icon - time.sleep(2) - home_frame = self.marionette.find_element('css selector', 'div.homescreen iframe') - self.marionette.switch_to_frame(home_frame) - - - def tearDown(self): - # Close the Marionette session now that the test is finished - self.marionette.delete_session() -</pre> - -<h2 id="テストファイルの更新">テストファイルの更新</h2> - -<p>作成された <code>test_base.py</code> ファイルを使用して、<code>TestBase</code>をテストファイルにインポートする必要があります。そして、テストクラスは、<code>TestBase</code>クラスを拡張するために変更される必要があります。:</p> - -<pre class="brush: python">import unittest -from marionette import Wait -from marionette import By -from test_base import TestBase - -class TestContacts(TestBase): - - def test(self): - # Tests in here - -if __name__ == '__main__': - unittest.main()</pre> - -<p>もう一度テストファイルを実行してみてください。</p> - -<p>今は多くのように見えないかもしれないが、あなたは数十または数百のテストがある場合、これは実際に重複したコードの多くを保存します。</p> diff --git a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_9_app_objects/index.html b/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_9_app_objects/index.html deleted file mode 100644 index 00dc7f472e..0000000000 --- a/files/ja/archive/b2g_os/automated_testing/gaia-ui-tests/part_9_app_objects/index.html +++ /dev/null @@ -1,141 +0,0 @@ ---- -title: 'パート 9: アプリオブジェクトの複製を抑える' -slug: Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_9_app_objects -tags: - - Automation - - Firefox OS - - Gaia - - Python - - app objects - - gaia-ui-tests - - tests -translation_of: Archive/B2G_OS/Automated_testing/gaia-ui-tests/Part_9_app_objects ---- -<p></p><section class="Quick_links" id="Quick_Links"> - -<ol> - <li class="toggle"> - <details> - <summary>Build and install</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS">Build and install overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_build_process_summary">B2G OS build process summary</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/B2G_OS_build_prerequisites">Build prerequisites</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Preparing_for_your_first_B2G_build">Preparing for your first build</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building">Building B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_installer_add-on">B2G installer add-on</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Building_for_Flame_on_OS_X">Building B2G OS for Flame on Mac OS X</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Choosing_how_to_run_Gaia_or_B2G">Choosing how to run Gaia or B2G OS</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/Compatible_Devices">Compatible Devices</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Installing_on_a_mobile_device">Installing B2G OS on a mobile device</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_OS_update_packages">Creating and applying B2G OS update packages</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building/FOTA_community_builds">Building and installing FOTA community builds</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Building_and_installing_B2G_OS/B2G_Build_Variables_Reference_Sheet">B2G build variables reference sheet</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Porting B2G OS</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS">Porting overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/basics">Porting basics</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Porting_B2G_OS/Porting_on_CyanogenMod">Porting on CyanogenMod</a></li> - </ol> - </details> - </li> - <li class="toggle"> - <details> - <summary>Developing Gaia</summary> - <ol> - <li><strong><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia">Developing Gaia overview</a></strong></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Running_the_Gaia_codebase">Running the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Mulet">Run Gaia on desktop using Mulet</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Understanding_the_Gaia_codebase">Understanding the Gaia codebase</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Making_Gaia_code_changes">Making Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Testing_Gaia_code_changes">Testing Gaia code changes</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Submitting_a_Gaia_patch">Submitting a Gaia patch</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Build_System_Primer">Gaia build system primer</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Different_ways_to_run_Gaia">Different ways to run Gaia</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/make_options_reference">Make options reference</a></li> - <li><a href="/ja/docs/Mozilla/B2G_OS/Developing_Gaia/Gaia_tools_reference">Gaia tools reference</a></li> - </ol> - </details> - </li> - <li><a href="/ja/docs/Mozilla/B2G_OS/API">B2G OS APIs</a></li> -</ol> -</section><p></p> - -<p></p><div class="prevnext" style="text-align: right;"> - <p><a href="/ja/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Part_8_Using_a_base_class" style="float: left;">« 前のページ</a><br></p> -</div><p></p> - -<div class="summary"> -<p><span class="seoSummary">自動テストでは、多くの場合、抽象コードに <code>app</code> のオブジェクトを使用します。これは、コードとロケータの重複を減らすことができます。コードの共通部分を変更する必要がある場合、むしろ10または20テストファイルでそれを変更することよりも、単一の <code>app</code> のオブジェクトに変更することができます。この記事では、<code>app</code> のオブジェクトを使用する方法の基礎を提供します。</span></p> -</div> - -<h2 id="アプリオブジェクト_入門">アプリオブジェクト: 入門</h2> - -<p><code>app</code> オブジェクトは、メソッド、ページ上のアクションを表すプロパティを含むPythonのクラスです。理論的な例では、これらを使用する方法を見てみましょう。</p> - -<h3 id="homepage.py">homepage.py</h3> - -<p>下記はいくつかの含まれている擬似コードとともに、ホームページのアプリのために使用する場合があるフレームです。</p> - -<pre class="brush: python">class Homepage: - __init__(self, marionette): - # Marionette is passed in so that the object can use it - self.marionette = marionette - - def switch_to_homepage_frame(self): - # Code for switching to System then to Homepage frame - - def tap_contacts_icon(self): - # Code to tap the icon - # Switch to Contacts frame - # Now we return the Contacts app object as it has focus - from contacts import Contacts - return Contacts(self.marionette)</pre> - -<h3 id="contacts.py">contacts.py</h3> - -<p>そしてここでいくつかの擬似コードで再度、連絡先アプリに使用するかもしれないものです。</p> - -<pre class="brush: python">class Contacts: - _new_contact_button = (By.ID, ‘id’) - - def tap_new_contact(self): - # Tap new contact icon - # Wait for event - - def type_given_name(self, name_string): - # element.send_keys(name_string)</pre> - -<h3 id="test_contacts.py"><strong>test_contacts.py</strong></h3> - -<p>これはテストのコンテキストでどのように機能するかを理解するために、下記は<code>Homepage</code> のクラスを利用した迅速なサンプルです。:</p> - -<pre class="brush: python">from homepage import Homepage - -def test_add_contact(self): - homepage = Homepage(self.marionette) - homepage.switch_to_homepage_frame() - -contacts = homepage.tap_contacts_icon() -contacts.tap_new_contact()</pre> - -<h2 id="テストを更新">テストを更新</h2> - -<p>ここからは、新しいアプリケーションのオブジェクトシステムを使用するようにテストのすべてのファイルを更新するために挑戦したいと思います。</p> - -<p>これは困難な作業であり、Pythonのクラス構造に慣れていない場合は、参照とコードサンプルのためのいくつかの書籍を参照する必要があります。</p> - -<p>完了したら、理想的には、テストファイル間の明確な分離を持っています:</p> - -<ol> - <li><code>TestBase</code>は、<code>setUp()</code> と <code>tearDown()</code> メソッドを含みます。</li> - <li><code>app</code> オブジェクトはページの相互作用とロケータが含まれています</li> - <li>テストファイルは、単にテスト手順が含まれます。</li> -</ol> - -<p>がんばろう!</p> diff --git a/files/ja/archive/b2g_os/automated_testing/gaia_performance_tests/index.html b/files/ja/archive/b2g_os/automated_testing/gaia_performance_tests/index.html deleted file mode 100644 index e6e132cf33..0000000000 --- a/files/ja/archive/b2g_os/automated_testing/gaia_performance_tests/index.html +++ /dev/null @@ -1,201 +0,0 @@ ---- -title: Gaia パフォーマンステスト -slug: Archive/B2G_OS/Automated_testing/Gaia_performance_tests -tags: - - Apps - - B2G - - Firefox OS - - QA -translation_of: Archive/B2G_OS/Automated_testing/Gaia_performance_tests ---- -<div class="summary"> -<h4 id="この記事ではGaiaのパフォーマンステスト実行に関する情報を、新規テストを作る方法と共に提供します。"><span class="seoSummary">この記事ではGaiaのパフォーマンステスト実行に関する情報を、新規テストを作る方法と共に提供します。</span></h4> -</div> - -<div class="warning"> -<p><strong>記:</strong> <code>test-perf</code> の使用と Datazilla は非推奨です。Gaia に関するパフォーマンステストの最新リソースは、<a href="https://developer.mozilla.org/ja/Firefox_OS/Automated_testing/Raptor">Raptor</a> を見て下さい。</p> -</div> - -<h2 id="テストを実行する">テストを実行する</h2> - -<p>テストは<a href="https://datazilla.mozilla.org/b2g/" title="https://datazilla.mozilla.org/b2g/">Datazilla</a>の通常の基礎の上で実行します; しかしながら、自分自身でも実行できます。このためには、<a href="/en-US/docs/Marionette" title="/en-US/docs/Marionette">Marionette</a> が有効でリモートデバッグが<strong>無効な</strong>エンジニアリングビルドが必要です。 この方法の詳細情報は、<a href="/en-US/docs/Mozilla/Firefox_OS/Platform/Gaia/Build_System_Primer#Customizing_the_preferences" title="/en-US/docs/Mozilla/Firefox_OS/Platform/Gaia/Build_System_Primer#Customizing_the_preferences">Gaia ビルドシステム入門の、設定カスタマイズ</a> を見て下さい。</p> - -<h3 id="テストの要求事項">テストの要求事項</h3> - -<p>2013/12/6 から <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=915156" title="FIXED: Port the performance testing framework to the new marionette runner">バグ 915156</a> が落ち着いたため、<code>make test-perf</code> はホスト上でテストを実行するのに Node.js が必要です。関連モジュールは <code>npm</code> で自動インストールされるでしょう。</p> - -<p>テストを実行する前に、実行ホストを調整する必要があります。実行ホストは<a href="/en-US/Firefox_OS/Using_the_B2G_desktop_client">B2G デスクトップ</a> や、端末上で (実際または仮想の — <a href="/en-US/Firefox_OS/Using_the_B2G_emulators">emulator</a>のように) テストを実行させるモジュールです。デフォルトではB2G デスクトップ内で実行して、これはパフォーマンスと深くは関連しません。実行ホストを調整するには、単にGaiaの最上位ディレクトリにある <code>local.mk</code> ファイルを編集して(存在しない場合は作成します)、次の行を加えます:</p> - -<pre class="brush: bash">MARIONETTE_RUNNER_HOST=marionette-device-host</pre> - -<p>これで端末の実行ホストを使えます。デフォルト値は<code>marionette-b2gdesktop-host</code> です。</p> - -<p>もう一つは次のようにします:</p> - -<pre class="brush: bash">MARIONETTE_RUNNER_HOST=marionette-device-host make test-perf </pre> - -<div class="note"> -<p><strong>記:</strong> 1つより多い端末が接続されている場合、<code>ANDROID_SERIAL環境変数をセットしなければなりません。</code>どの値を使うかを知るには、<code>adb devices</code> を見ます。<a href="/en-US/Firefox_OS/Platform/Gaia/Hacking">更新済の Gaia バージョンを実行している</a>のを確認します。</p> -</div> - -<h3 id="出力">出力</h3> - -<p>By default the test output the data in JSON format. By default it is output to <code>stdout</code> and might be mixed with error message from other commands like <code>npm</code>. This is not a very good idea for automation. So you can redirect this JSON output to a file. Just define <code>MOZPERFOUT</code> for the host runner, either on the command line as an option or in the <code>local.mk</code> file as shown above.</p> - -<pre class="brush: bash">MOZPERFOUT=myfile.json</pre> - -<p>There is a "spec" reporter that allow reporting the output in a more human readable format. To use it, set the environment as follow:</p> - -<pre class="brush: bash">REPORTER=ConsoleMozPerf</pre> - -<p>This will make the test output something easier to read. Not easier to parse. There is no real syntax.</p> - -<p>For now, any other value will use the JSON reporter.</p> - -<div class="note"> -<p><strong>Note:</strong> <code>MOZPERFOUT</code> will be honoured whichever reporter you select.</p> -</div> - -<h3 id="全てのテストを実行する">全てのテストを実行する</h3> - -<p>In general you can run these tests on 1.4 and upwards from Gaia master. 1.3 might no longer be able to handle the test runs. There is an exception for 1.3t (Tarako). since <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1006064" title="FIXED: Port make test-perf to 1.3T">バグ 1006064</a> landed, if you want to run the tests against Tarako (1.3t), you should run it from the Gaia 1.3t. From 2.0 and onwards, we consider that you should run the test from the same Gaia tree.</p> - -<p>To run all the tests, use the following command:</p> - -<pre class="brush: bash">make test-perf</pre> - -<div class="note"> -<p><strong>Note</strong>: Since early August 2014 (currently only on master) the b2g process is restarted after each test, not after each test run, to improve the reliability of the tests (see <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1027232" title="FIXED: We should restart b2g before each app tests">バグ 1027232</a>). If you want to disable this, set the <code>RESTART_B2G</code> environment variable to "0" when running the tests.</p> -</div> - -<h3 id="特定アプリのテストを実行する">特定アプリのテストを実行する</h3> - -<p>This is done by naming the app you want to run the tests for, in the <code>APP</code> variable, for example:</p> - -<pre class="brush: bash">APP=browser make test-perf</pre> - -<h3 id="一連のアプリのテストを実行する">一連のアプリのテストを実行する</h3> - -<p>You can also specify a set of apps, inside the <code>APPS</code> variable, to run the tests against a specific set:</p> - -<pre class="brush: bash">APPS="browser communications/contacts" make test-perf</pre> - -<h3 id="実行数の設定">実行数の設定</h3> - -<p>By default, each test is run five times. You can change that by setting the value of <code>RUNS</code> before running the tests. For example, to run each test three times you'd use this option:</p> - -<pre class="brush: bash">RUNS=3 make test-perf</pre> - -<h3 id="既知の問題">既知の問題</h3> - -<p>When running test on Buri/Hamachi (Alcatel one touch fire), you get:</p> - -<pre>Not enough fields given the number of keys.</pre> - -<p>You can safely ignore the warning. It is just that <code>b2g-info</code> on the device is too old as it comes from 1.2 and we only change Gecko and Gaia on these.</p> - -<h2 id="新規テストを書く">新規テストを書く</h2> - -<p>With the details of running the test suite out the way, let's now look at how you can write your own performance tests for Gaia.</p> - -<h3 id="スタートアップイベントのテスト">スタートアップイベントのテスト</h3> - -<p>We have setup a standard for app startup events. If you want to test the app startup, please follow the <a href="https://developer.mozilla.org/en-US/Apps/Build/Performance/Firefox_OS_app_responsiveness_guidelines">responsiveness guidelines</a>. The <code>startup_event_test.js</code> test will drive it. Make sure to whitelist your app in <code>/tests/performance/config.json</code>, by adding it to the list specified by <code>mozLaunch</code>.</p> - -<div class="note"> -<p><strong>Note:</strong> This is only implemented in v2.0 and later. If your code uses <code>startup-path-done</code> events then it is using the deprecated style and should be updated.</p> -</div> - -<p>If you want to measure intermediate launch stages that are not part of the reponsiveness standard, you can dispatch these using the method described below. Dispatching performance events is all you need, they will be collected automatically.</p> - -<h3 id="他のイベントに基づくテスト">他のイベントに基づくテスト</h3> - -<p>Now if you want to test specific features in your app you can do so by sending events. The test will be in two part. The instrumentation part that lives in the app itself, and the control part that will use marionette to control the app to perform actions.</p> - -<h4 id="Instrumentation">Instrumentation</h4> - -<p>To record the events, all you have to do is dispatch them.</p> - -<p>First, include our helper in your app:</p> - -<pre class="brush: html"><script src="/shared/js/performance_testing_helper.js"></script> -</pre> - -<div class="note"> -<p><strong>Note</strong>: The use of module loaders like RequireJS or Alameda, are perfectly acceptable provided it is loaded before any performance events are triggered.</p> -</div> - -<p>You need to be cautious and make sure you adjust the <a href="/en-US/Firefox_OS/Platform/Automated_testing/Gaia_unit_tests">unit tests</a> so that the <code>PerformaceTestingHelper</code> is either loaded or shimmed. A simple shim is to put this in the unit test source file:</p> - -<pre class="brush: js">var PerformanceTestingHelper = { - dispatch: function() { } -}; -</pre> - -<p>The Travis CI jobs we run out of Github will error if you don't do that properly.</p> - -<p>Having done that, you can use the helper to dispatch events when it seems appropriate to do so. First you should dispatch a start event. It is important as the '<code>start</code>' event is sent when we register the listeners, so for your feature you likely want to do this much later. So choose where the feature start and add the proper event dispatch.</p> - -<pre class="brush: js">PerformanceTestingHelper.dispatch('my-feature-start'); -</pre> - -<p>When you're ready to stop collecting data and to report the numbers, you need to send the <code>my-feature-done</code> event, also called the last event, to tell the helper to finish:</p> - -<pre class="brush: js">PerformanceTestingHelper.dispatch('my-feature-done');</pre> - -<p>Also you might want to send intermediate events as appropriate.</p> - -<div class="note"> -<p><strong>Note:</strong> Here we use "my-feature-" as a prefix for the performance event. This is just an example. Please use an obvious name and try to use it consistently.</p> -</div> - -<h4 id="アプリをコントロールする">アプリをコントロールする</h4> - -<p>The second part is writing JavaScript to the test framework to perform the test. The filename must end with <code>_test.js</code> and live in <code>apps/<myapp>/test/performance/</code>.</p> - -<p>It is a lot like a marionette integration test (based on mocha), but with a few twists: in the <code>setup()</code> function you must inject the helper atom that is being used to collect the performance events.</p> - -<pre class="brush: js">PerformanceHelper.injectHelperAtom(client);</pre> - -<p>You must pass a <code>lastEvent</code> parameter to the <code>PerformanceHelper</code> constructor. This will be the last event on which to wait to test your feature.</p> - -<p>When calling <code>performanceHelper.reportRunDurations()</code> toward the end you must pass the name of the start event you dispatched, otherwise the measurement will be from the start, ie when we inject the helper atom. An easy to figure out the error is if you see the start event in the results. And in that case you'll the the startup events as well as these will be dispatched too.</p> - -<div class="note"> -<p><strong>Note:</strong> You should study existing tests to get a become more familiar with the process.</p> -</div> - -<h3 id="メモリの統計情報を集める">メモリの統計情報を集める</h3> - -<p>You can collect the memory usage for both the b2g process and the current app. Just do</p> - -<pre class="brush: js">var memUsage = performanceHelper.getMemoryUsage(app);</pre> - -<p><code>app</code> is the application object. <code>memusage</code> will contain several objects enumerating the memory statistics.</p> - -<h2 id="非エンジニアリング端末でテスト実行する">非エンジニアリング端末でテスト実行する</h2> - -<p>If you don't have an engineering build on your phone you'll have to do some additional steps:</p> - -<ol> - <li>Clone B2G, and build with <code>./config.sh DEVICE-NAME</code> (e.g. <code>./config.sh keon</code>)</li> - <li>Build the Gecko part via <code>./build.sh gecko</code></li> - <li>Connect the phone and flash gecko via <code>./flash.sh gecko</code></li> - <li>Clone Gaia, and create a file <code>build/custom-prefs.js</code> with content <code>user_pref("marionette.defaultPrefs.enabled", true);</code></li> - <li>Enable <a href="/en-US/Firefox_OS/Debugging/Developer_settings#Remote_debugging">Remote Debugging</a> on the phone and run <code>make reset-gaia</code> to reset the phone (or <code>make install-gaia</code> if you trust yourself)</li> - <li>Disable Remote Debugging and verify that everything is OK by running <code>adb devices</code>. The device should show up.</li> - <li>Now running a perf test should work. Verify via <code>RUNS=1 APP=browser make test-perf</code></li> -</ol> - -<h2 id="バグ登録する">バグ登録する</h2> - -<p>Please <a href="https://bugzilla.mozilla.org/enter_bug.cgi?product=Firefox%20OS">file bugs in Bugzilla</a>, product "Firefox OS", component "Gaia::PerformanceTest".</p> - -<h2 id="参考情報">参考情報</h2> - -<ul> - <li><a href="/en-US/docs/Marionette" title="/en-US/docs/Marionette">Marionette</a></li> - <li><a href="/en-US/docs/Mozilla/Firefox_OS/Platform/Testing" title="/en-US/docs/Mozilla/Firefox_OS/Platform/Testing">Testing Firefox OS</a></li> -</ul> - -<div style="background-color: transparent; color: #000000; position: absolute; top: 189px; left: 180px; padding: 0px; border-radius: 2px;" id="divLookup"><img></div> diff --git a/files/ja/archive/b2g_os/automated_testing/gaia_unit_tests/index.html b/files/ja/archive/b2g_os/automated_testing/gaia_unit_tests/index.html deleted file mode 100644 index 67e236098f..0000000000 --- a/files/ja/archive/b2g_os/automated_testing/gaia_unit_tests/index.html +++ /dev/null @@ -1,119 +0,0 @@ ---- -title: Gaiaユニットテスト -slug: Archive/B2G_OS/Automated_testing/Gaia_unit_tests -translation_of: Archive/B2G_OS/Automated_testing/Gaia_unit_tests ---- -<div class="summary"> - <p>Gaia/B2Gソースコードの一部として、GaiaとB2Gの異なる側面をテストするために、さまざまなユニットテストが使用可能になった。この記事ではこれらにアクセスする方法について解説します。</p> -</div> -<div class="note"> - <p><strong>注意</strong>: このドキュメントではあなたがGaiaとB2Gを動かす方法を理解していると仮定しています。Gaiaの開発を開始するには<a href="/ja/Firefox_OS/Developing_Gaia">Gaiaの開発</a>を見てください。</p> -</div> -<h2 id="ユニットテストを実行する">ユニットテストを実行する</h2> -<p><a href="/ja/docs/Mozilla/Boot_to_Gecko/Using_the_B2G_desktop_client">B2Gデスクトップ</a>か<a href="http://nightly.mozilla.org/">Firefox Nightly</a>でユニットテストを実行することができます。また最新の<a href="https://github.com/mozilla-b2g/gaia/">Gaiaリポジトリ</a>が必要です。ほとんどの機能のために<a class="external" href="http://nodejs.org/" title="http://nodejs.org/">Node.js</a>と<a class="external" href="http://npmjs.org/" title="http://npmjs.org/">NPM</a>がインストールされている必要があります。</p> -<div class="note"> - <p><strong>注意</strong>: もし以下のコマンドがtest-agentの依存関係をインストール中に暗号に関するエラーで失敗したら、Node.js/NPMのバージョンが古すぎることに起因しているかもしれません。新しいバージョンをインストールし<code>node_modules/test-agent</code>フォルダを削除するために<a href="https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager">パッケージマネージャによってNode.jsをインストールする</a>を読んでください。</p> -</div> -<p>Gaiaリポジトリにはテストの実行が簡単になるように便利な<code>bin/gaia-test</code>スクリプトが同梱されます。</p> -<div class="note"> - <p><strong>注意してください:</strong>このスクリプトは<code>profile-debug</code>のユニットテストに適したプロファイルを生成します。すでにこのディレクトリに別のプロファイルがある場合それを上書きします。<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=980496">Bug 980496</a>ではこれをコンフィグ可能にすることを目指しています。</p> -</div> -<h3 id="Firefoxでテストランナーを起動する">Firefoxでテストランナーを起動する</h3> -<p>テストサーバとPATHから見つかるデフォルトのFirefoxを起動します:</p> -<pre class="brush: bash">bin/gaia-test</pre> -<h4 id="Firefoxのバイナリを選択する">Firefoxのバイナリを選択する</h4> -<p>FIREFOX環境変数にFirefoxバイナリのパスをexportすることができる。例えばOS Xの場合:</p> -<pre class="brush: bash">export FIREFOX=/Applications/FirefoxNightly.app/Contents/MacOS/firefox</pre> -<p>或いは、bin/gaia-testへの引数として渡すこともできます:</p> -<pre class="brush: bash">bin/gaia-test <gaia directory> <firefox path></pre> -<h3 id="B2Gデスクトップでテストランナーを起動する">B2Gデスクトップでテストランナーを起動する</h3> -<p>ダウンロードとB2Gデスクトップの起動:</p> -<pre class="brush: bash">bin/gaia-test -d</pre> -<h3 id="Webインターフェイスからのテスト実行">Webインターフェイスからのテスト実行</h3> -<p>特定のテストと<em>Execute</em>ボタンをシンプルにクリックすることでできます。</p> -<h3 id="コマンドラインからのテスト実行">コマンドラインからのテスト実行</h3> -<p>以下のコマンドでWebSocketサーバを実行し、B2G Desktop/Firefox Nightlyでテストエージェントアプリを実行します:</p> -<pre>make test-agent-test -</pre> -<p>If you only want to run one app's tests you can specify which via the <code>APP</code> env variable:</p> -<pre>make test-agent-test APP=calendar -</pre> -<p>また必要に応じてテスト出力を整形するための<a class="external" href="http://visionmedia.github.com/mocha/#reporters" title="http://visionmedia.github.com/mocha/#reporters">レポータ</a>を提供することができます:</p> -<pre>make REPORTER=List test-agent-test -</pre> -<div class="note"> - <strong>注意:</strong>現在Docをサポートしていないので、全てのリポータが動くわけではありません。</div> -<h3 id="Run_the_tests_as_you_save">Run the tests as you save</h3> -<p>When the server is running, the tests for a file are run automatically when a file is saved or even just touched:</p> -<ul> - <li>When you save a test file, the test file itself is run</li> - <li>When you save another file, it finds a matching file in the <code>test/unit</code> directory, by suffixing the file name with <code>_test.js</code>.</li> -</ul> -<div class="note"> - <p><strong>Note: </strong>It watches only existing files so if you create a new file, you have to restart the agent.</p> -</div> -<h3 id="Running_tests_like_TBPL_does">Running tests like TBPL does</h3> -<p>Gaia unit tests in TBPL are run using a separate runner; this explains how to use it. Please consult the <a href="/en-US/docs/Python/Virtualenv" title="/en-US/docs/Python/Virtualenv">virtualenv</a> docs if you're not familiar with using a Python virtualenv.</p> -<pre class="brush: bash">virtualenv venv -source venv/bin/activate -cd $GAIA/tests/python/gaia-unit-tests -python setup.py develop -cd gaia_unit_test -python main.py --binary /path/to/b2g/desktop/build --profile /path/to/gaia/profile -</pre> -<div class="note"> - <p><strong>Note</strong>: When specifying the path to the B2G desktop build, you should specify the path to <code>b2g-bin</code>, if it exists, otherwise use <code>b2g</code>.</p> -</div> -<p>The Gaia profile must be made using the following:</p> -<pre class="brush: bash">NO_LOCK_SCREEN=1 DEBUG=1 DESKTOP=0 make</pre> -<p>By default, this profile will be generated in <code>$GAIA/profile-debug</code>. <code>bin/gaia-test</code> generates the same profile so you don't need to regenerate it if you already run <code>gaia-test</code>.</p> -<h3 id="Disabling_a_gaia_unit_test_in_TBPL">Disabling a gaia unit test in TBPL</h3> -<p>TBPL uses a blacklist to exclude certain gaia unit tests from being run. To prevent a test from running in TBPL, add its path to <a href="https://github.com/mozilla-b2g/gaia/blob/master/tests/python/gaia-unit-tests/gaia_unit_test/disabled.json">https://github.com/mozilla-b2g/gaia/blob/master/tests/python/gaia-unit-tests/gaia_unit_test/disabled.json</a>.</p> -<h2 id="Setting_up_your_Gaia_app">Setting up your Gaia app</h2> -<p>Although this guide should help make things easier, the best way to learn how to write, set up, and run tests is currently still to look at the source code; in particular, take a look at the <a class="link-https" href="https://github.com/lightsofapollo/gaia/tree/master/apps/gallery/test" title="https://github.com/lightsofapollo/gaia/tree/master/apps/gallery/test">gallery tests</a>.</p> -<h3 id="Loading_your_own_test_files" style="line-height: 24px; font-size: 1.71428571428571rem;">Loading your own test files</h3> -<div class="note"> - <p><strong>Note</strong>: This is an advanced and entirely optional technique. If test-agent's native test loader is working for your application and your test style, and you don't want to use your own test files, this section is not for you!</p> -</div> -<p>Test-agent loads your test files in an environment where they have access to mocha (among other bits of global state). One important test-agent global is <code>require</code>, which allows your test file to load a dependency (application code for instance). Sometimes, particularly if your application files expect to be loaded in a way that's different from test-agent's <code>require</code>, it can be useful to override test-agent's test file loader. You can do so in the following manner:</p> -<pre class="brush: js" style="font-size: 14px;">// setup.js - -testAgentRuntime.testLoader = function(path) { - // We're going to return a promise to represent - // the loading state of the test file at this path. - return new Promise((accept, reject) => { - // Load the parameter test file and resolve (or reject) appropriately - // ... - }); -};</pre> -<h2 id="Using_mocks">Using mocks</h2> -<p>TBD</p> -<h2 id="Advanced_what_does_the_script_do">Advanced: what does the script do?</h2> -<h3 id="Generating_a_profile">Generating a profile</h3> -<p>You need a profile that is generated by this command:</p> -<pre class="brush: bash">NO_LOCK_SCREEN=1 DEBUG=1 DESKTOP=0 make -</pre> -<p>This generates a debug profile in <code>gaia/profile-debug</code>, overriding a previous profile if you already have one.</p> -<ul> - <li><code>DEBUG=1</code> enables the <em>httpd.js</em> extension that makes it possible to directly use the files from the <code>apps/</code> directory.</li> - <li><code>NO_LOCK_SCREEN=1</code> disables the lock screen, which is necessary in B2G Desktop because it's not possible to unlock it using the mouse.</li> - <li><code>DESKTOP=0</code> disables the other addons we normally use in DEBUG mode to run Gaia in Firefox.</li> -</ul> -<h3 id="Launch_the_WebSocket_server">Launch the WebSocket server</h3> -<p>Test agent (the test runner) ships with a built in WebSocket server that lets you remotely message the browser or device to queue a test run. Often you will want to develop with time saving features like a file watcher that will run your tests when a test file or implementation changes. To take advantage of these features you need to start the server:</p> -<pre class="brush: bash">make test-agent-server -</pre> -<p>Using the WebSocket server provides other tools such as a command line reporter for test results (watch the terminal you ran the command from), a Growl reporter, syntax error notifications, and more.</p> -<p>The agent also watches for modifications in files, and automatically runs the associated tests. It runs when you save the test or if you save the tested file (we use the convention where the test filename is the tested filename with <code>_test</code> appended,<code> </code>see below for more examples). It watches only existing files so if you create a new file, you have to restart the agent.</p> -<h3 id="Running_unit_tests_with_Firefox_Nightly">Running unit tests with Firefox Nightly</h3> -<p>You can launch Gaia in Firefox Nightly with the following commands:</p> -<pre class="brush: bash">cd <path to gaia> -<path to nightly>/firefox --no-remote -profile <path to gaia>/profile-debug/ http://test-agent.gaiamobile.org:8080/</pre> -<div class="note"> - <p><strong>Note</strong>: In OS X, The profile path should be absolute path</p> -</div> -<p>You can use Firebug or the integrated debugger to debug the tests; use the <code>debugger</code> keyword to break in the debugger.</p> -<h3 id="Running_unit_tests_with_B2G_Desktop">Running unit tests with B2G Desktop</h3> -<p>Launch Gaia and start the "Test Agent" app. From the Test gent app you can select tests to run from the UI.</p> -<h2 id="Advanced_how_does_the_test-agent_work">Advanced: how does the test-agent work?</h2> -<p>The Test Agent lives in<a href="https://github.com/mozilla-b2g/js-test-agent"> its own Github repository</a>. You can have look there to understand how it works under the hood.</p> diff --git a/files/ja/archive/b2g_os/automated_testing/index.html b/files/ja/archive/b2g_os/automated_testing/index.html deleted file mode 100644 index 0ab927239b..0000000000 --- a/files/ja/archive/b2g_os/automated_testing/index.html +++ /dev/null @@ -1,97 +0,0 @@ ---- -title: Firefox OSの自動テスト -slug: Archive/B2G_OS/Automated_testing -tags: - - Automated testing - - QA - - Testing -translation_of: Archive/B2G_OS/Automated_testing ---- -<p></p> - -<div class="summary"> -<p>Firefox OSはまだ開発中であり、新しいハードウェアのサポートが間近に迫っていることを考えれば、テストの仕方を知ることは今後重要になると言えます。<span class="seoSummary">このページは複数の違うテストの実行、自動化、そして結果のレポートとトラッキングを含む、Firefox OSのテストの多角的な側面に関する情報の記事を提供しています。</span></p> -</div> - -<h2 id="導入">導入</h2> - -<dl> - <dt><a href="/Firefox_OS/Running_Tests_on_Firefox_OS_for_Developers">Firefox OS上でテストを実行する: 開発者向けガイド</a></dt> - <dd>まずは、開発者に注目したテスト実行の導入ガイドです。もしあなたがMozillaのテスト実行と自動化システムを経験していないならまず読んでください。すでにテストを経験しているなら、おそらく実行したいテストと方法のアイデアにあわせて、以下のより特化した詳細なガイドにスキップできます。</dd> -</dl> - -<h2 id="Gaiaのテスト">Gaiaのテスト</h2> - -<p>これらの記事はGaiaの性能を試す試験を受けさせるように設計された主なテストスイートをカバーします。</p> - -<dl> - <dt><a href="/Firefox_OS/Platform/Automated_testing/gaia-ui-tests" title="/en-US/docs/Mozilla/Firefox_OS/Platform/Testing/gaia-ui-tests">Gaia UIテスト</a></dt> - <dd>Gaia UIの相互作用と機能のPython製テスト。</dd> - <dt><a href="/docs/Mozilla/Firefox_OS/Platform/Automated_testing/Gaia_integration_tests">Gaia総合テスト</a></dt> - <dd>JavaScriptによるMarionetteベースのGaia総合テスト。</dd> - <dt><a href="/docs/Mozilla/Firefox_OS/Platform/Automated_testing/Gaia_unit_tests" title="/en-US/docs/Mozilla/Firefox_OS/Platform/Testing/Gaia_unit_tests">Gaiaユニットテスト</a></dt> - <dd>GaiaのUI相互作用を伴わないユニットテスト; Marionetteベースではないが、JavaScriptで書かれています。</dd> - <dt><a href="https://developer.mozilla.org/en-US/Firefox_OS/Automated_testing/Raptor">Raptor: Performance Tools for Gaia</a></dt> - <dd>Raptor はFirefox OSに特化したパフォーマンス測定ツールで、既存のパフォーマンステストツールを改良するのを狙っています。</dd> - <dt><a href="https://wiki.mozilla.org/Project_Eideticker" title="https://github.com/mozilla/eideticker">Eideticker</a></dt> - <dd>ビデオキャプチャベースでFirefox OSにパフォーマンス計測を提供します。</dd> -</dl> - -<p><strong><a href="/docs/Mozilla/Firefox_OS/Platform/Automated_testing/MTBF_tests">MTBFテスト</a></strong></p> - -<dl> - <dd>MTBFテストは再開しないgaia-ui-testベースのテストフレームワークです。MTBFテストは長時間テストを妨げる種類の問題の特定を試します。(現在はまだ発展途上のテストフレームワークであり、台湾QAチームが所有しています)</dd> -</dl> - -<h2 id="B2Gのテスト">B2Gのテスト</h2> - -<p>以下のガイドはB2Gの機能性の様々な側面をテストする異なる数のテストハーネスをカバーします。</p> - -<dl> - <dt><a href="/docs/Mozilla/Firefox_OS/Platform/Automated_testing/Mochitests" title="/en-US/docs/Mozilla/Firefox_OS/Platform/Testing/Mochitests">Mochitests</a></dt> - <dd>Geckoの機能とAPIのテスト; HTML & JSベース。Gaiaと相互作用しません。</dd> - <dt><a href="/docs/Mozilla/Firefox_OS/Platform/Automated_testing/Reftests" title="/en-US/docs/Mozilla/Firefox_OS/Platform/Testing/Reftests">Reftests</a></dt> - <dd>Geckoのレンダリング正確性テスト。</dd> - <dt><a href="/docs/Mozilla/QA/Marionette/Marionette_JavaScript_Tests" title="/ja/docs/Mozilla/QA/Marionette/Marionette_JavaScript_Tests">WebAPIのテスト</a></dt> - <dd>GeckoのJSベースのWebAPIテスト; ほとんどにエミュレータが必要になります。</dd> - <dt><a href="/Firefox_OS/Platform/Testing/XPCShell" title="/ja/Firefox_OS/Platform/Testing/XPCShell">xpcshellのテスト</a></dt> - <dd>GeckoのXPCOM APIsのヘッドレステスト。</dd> - <dt><a href="/Firefox_OS/Automated_testing/Cppunit" title="/en-US/docs/Mozilla/Firefox_OS/Automated_testing/Cppunit">cppunit tests</a></dt> - <dd>C++ 単体のヘッドレステスト。</dd> -</dl> - -<h2 id="解説ドキュメント">解説ドキュメント</h2> - -<p>このセクションはMozillaのテストについて詳細な情報を探すなら、テストに根拠を与えるいくつかの技術解説へのリンクを提供します。</p> - -<dl> - <dt><a href="/docs/Mozilla/QA/Marionette" title="/ja/docs/Mozilla/QA/Marionette">Marionette</a></dt> - <dd>Selenium WebDriverベースのリモートテストドライバ。</dd> - <dt><a href="/docs/Marionette/Marionette_JavaScript_Tools" title="/en-US/docs/Marionette/Marionette_JavaScript_Tools">Marionette JavaScript tests</a></dt> - <dd>node.jsベースのMarionetteテストランナー。</dd> - <dt><a href="/docs/Marionette/Python_Marionette" title="/en-US/docs/Marionette/Python_Marionette">Marionette Python client</a></dt> - <dd>Python版Marionetteテストランナー。</dd> - <dt><a href="https://wiki.mozilla.org/Build:TryServer">Try server</a></dt> - <dd>Mozilla's standard server for testing patches before checking them into the core repository. See also the <a href="http://trychooser.pub.build.mozilla.org/">TryChooser Syntax Builder</a>.</dd> -</dl> - -<div class="note"> -<p><strong>注意</strong>: もし製品版ビルドに対してMarionetteを実行したいなら (gaia総合テスト、gaia-ui-tests、等の実行)、<a href="https://github.com/mozilla-b2g/marionette-extension">拡張機能としてMarionetteをインストール</a>することができます (今は1.3ビルドのみ動きますが、他のサポートもすぐに追加されます)</p> -</div> - -<h2 id="継続的インテグレーションと結果報告">継続的インテグレーションと結果報告</h2> - -<p>以下の記事はMozillaがテストデータの保存と解釈するのに使用する継続的インテグレーションと結果報告のメカニズムをカバーします。</p> - -<dl> - <dt><a href="/docs/Mozilla/Firefox_OS/Treeherder">Treeherder</a></dt> - <dd>Treeherderによるテストとビルドを理解することができます。</dd> - <dt><a href="https://raptor.mozilla.org/">Raptor</a></dt> - <dd>Visualization of performance tests run against the <a href="https://developer.mozilla.org/en-US/Firefox_OS/Automated_testing/Raptor">Raptor</a> tool.</dd> - <dt><a href="/docs/Mozilla/Firefox_OS/Platform/Automated_testing/Test_Execution_Chart" title="/en-US/docs/Mozilla/Firefox_OS/Testing/Test_Execution_Chart">Test execution chart</a></dt> - <dd>テストが実行開始しているか、どのデバイス上でまたはどこでテストしているか、そして各テストがどのパフォーマンスをサポートしているかのチャートを見ることができます。</dd> -</dl> - -<h2 class="Community" name="Community" id="Community">ユニットテストフレームワークのビデオ</h2> - -<p></p><div class="intrinsic-wrapper"><div class="intrinsic-container "><iframe src="https://www.youtube.com/embed/LxnRIm0wLLo?rel=0&html5=1"></iframe></div></div><p></p> diff --git a/files/ja/archive/b2g_os/automated_testing/raptor/index.html b/files/ja/archive/b2g_os/automated_testing/raptor/index.html deleted file mode 100644 index 81895511e1..0000000000 --- a/files/ja/archive/b2g_os/automated_testing/raptor/index.html +++ /dev/null @@ -1,442 +0,0 @@ ---- -title: 'Raptor: Gaia用パフォーマンスツール' -slug: Archive/B2G_OS/Automated_testing/Raptor -tags: - - Firefox OS - - Performance - - Raptor - - User Timing -translation_of: Archive/B2G_OS/Developing_Gaia/Raptor ---- -<div class="summary"> -<p>この記事は Raptor について説明します: これは、特に Firefox OS に関するパフォーマンス計測用のCLI(コマンドライン)ツールです。これはツールの機能の背後にある戦略を見て、ツールを始める方法を示してくれて、先進トピック、例えば自身のテストを書いたり、可視化したり、自動化したりに移動できます。</p> -</div> - -<p>Raptor は、以前のツール <code>make test-perf でパフォーマンステストをする時に直面する、たくさんの落とし穴</code>を克服することを狙っています:</p> - -<ul> - <li><code>test-perf</code> ツールは、アプリが読み込みのライフサイクルでキーポイントで発行するイベントをリッスンするのに、 Marionette.js に依存していました。これは、あらゆるアプリのイベント毎にイベントリスナーをバインドするように、atomスクリプトが挿入されるのを要求します。仮想標準イベントがキャプチャされる毎に、スクリプトは変更されないといけません。これはMarionette.js 自体を使うことの上にオーバーヘッドがあり、多くのメンテナンス時間を意味します。</li> - <li>パフォーマンスイベントを作る API は一貫していません。標準パフォーマンスイベントを簡単にキャプチャするために、<code>test-perf</code> ではカスタムイベントを投げることで行われていました。たとえば <code>window.dispatchEvent(new CustomEvent('moz-app-visually-complete'))</code>。不幸にも、アプリが自身のパフォーマンスイベントを発行した場合、パフォーマンステストのヘルパースクリプトから、別のAPI を使わなければいけませんでした。</li> - <li>あらゆるアプリがパフォーマンステストのヘルパースクリプトを入れないといけません。このスクリプトは API がパフォーマンスイベントにアクセスするのに必要ではありますが、それ自身についてのオーバーヘッドとメンテも必要になります。</li> - <li><code>test-perf</code> ツールはコア Gaia アプリのパフォーマンスメトリクスを集めるのに適していますが、それ以外の多くを扱うように拡張するのは難しいです。ホームスクリーンや、システムや、アプリ起動以外のインタラクションを、このフレームワーク空間内でテストするのはとても難しいです。</li> -</ul> - -<p>Raptor はこうした問題を解決し、より効率的で拡張性の高く、自身に多くのオーバーヘッドを加えないテストフレームワークを提供するように、設計されました。</p> - -<h2 id="戦略">戦略</h2> - -<p>この章では、Raptorの機能を実装する中で取られた戦略について述べます。.</p> - -<h3 id="ユーザタイミング">ユーザタイミング</h3> - -<p><a href="http://www.w3.org/TR/user-timing/">ユーザタイミング API</a> は、カスタムパフォーマンス指標と計測とを指し示すメカニズムとwebドキュメントを提供しています。標準化されたAPIを使うことで、パフォーマンスイベントを無視するヘルパースクリプトをアプリが同梱しないといけなくなるのを回避できます。実際に、ユーザタイミングは、全くイベントに依存していません。</p> - -<pre class="brush: js language-js"><code class="language-js"><span class="comment token">// Legacy performance events -</span>window<span class="punctuation token">.</span><span class="function token">dispatchEvent<span class="punctuation token">(</span></span><span class="keyword token">new</span> <span class="class-name token">CustomEvent</span><span class="punctuation token">(</span><span class="string token">'moz-app-visually-complete'</span><span class="punctuation token">)</span><span class="punctuation token">)</span><span class="punctuation token">;</span> -PerformanceTestingHelper<span class="punctuation token">.</span><span class="function token">dispatch<span class="punctuation token">(</span></span><span class="string token">'settings-load-start'</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> - -<pre class="brush: js language-js"><code class="language-js"><span class="comment token">// User Timing API -</span>performance<span class="punctuation token">.</span><span class="function token">mark<span class="punctuation token">(</span></span><span class="string token">'visuallyLoaded'</span><span class="punctuation token">)</span><span class="punctuation token">;</span> - -performance<span class="punctuation token">.</span><span class="function token">mark<span class="punctuation token">(</span></span><span class="string token">'settingsStart'</span><span class="punctuation token">)</span><span class="punctuation token">;</span> -performance<span class="punctuation token">.</span><span class="function token">mark<span class="punctuation token">(</span></span><span class="string token">'settingsEnd'</span><span class="punctuation token">)</span><span class="punctuation token">;</span> - -performance<span class="punctuation token">.</span><span class="function token">measure<span class="punctuation token">(</span></span><span class="string token">'settingsLoad'</span><span class="punctuation token">,</span> <span class="string token">'settingsStart'</span><span class="punctuation token">,</span> <span class="string token">'settingsEnd'</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> - -<h3 id="ロギング">ロギング</h3> - -<p>パフォーマンスに影響するのを避けるように、アプリケーションから切り離したやり方でパフォーマンスエントリを捕捉するために、我々はパフォーマンスのメタデータを端末のログストリームに出力することを選びました、すなわち <code>adb logcat</code> です。Raptor はこのストリームを消費して、メトリクスを集めるログからパフォーマンスエントリを解析します。</p> - -<h3 id="sect1"> </h3> - -<h3 id="Phases_と拡張性">Phases と拡張性</h3> - -<p>Raptor は "phases"という概念を導入し、これは汎用的な方法でテストの相互作用をするためのフレームワークを置くものです。現在、Raptor はコールド起動と、再起動、B2Gの再起動を、計画済みの追加フェーズでサポートしています。これらの作業は、端末をパフォーマンス測定前のあるフェーズに配置することで、実際のパフォーマンステストのロジックをより簡単にします。</p> - -<h3 id="端末のインタラクション">端末のインタラクション</h3> - -<p>Raptor works to abstract device interactions. Some of its major features are as follows:</p> - -<ul> - <li>Raptor uses the Marionette.js client for familiar device interactions using a high-level API. The same Marionette.js client used for writing integration tests can be used for trigger device actions which contain performance measurements.</li> - <li>For low-level interactions, Raptor relies on the low-level <a href="https://github.com/wlach/orangutan">Orangutan</a> tool for triggering touch events. This works by injecting coordinate-based touch events directly into the driver interface, e.g. <code>/dev/input/event0</code> on a Firefox OS Flame. This has the benefit of simulating the touch event through the OS very transparently. In addition, trigger touch events have a similar API for triggering, e.g. triggering a tap may look like: <code>device.input.tap(300, 400, 1)</code>, which simulates a single tap at XY coordinates (300,400).</li> - <li>All calls to and from the logging interface (i.e. <code>adb logcat</code>) have a consistent and managed JavaScript-based API.</li> - <li>Raptor also has interfaces for pushing and pulling files to/from devices.</li> -</ul> - -<h2 id="さぁ始めよう">さぁ始めよう</h2> - -<div class="note"> -<p><strong>NOTE:</strong> While Raptor can be run on emulators, the results should not be relied on for performance comparisons. Desktop computers and their power means that they are not comparable to the performance characteristics of devices and end users, and should not be used for time-based decision making.</p> -</div> - -<h3 id="前提条件">前提条件</h3> - -<p>You must have a copy of <a href="https://github.com/mozilla-b2g/gaia/">Gaia</a> v2.2+ available on your system, as well as Node.js v0.12+/npm v2+ installed.</p> - -<h3 id="Raptorのインストール">Raptorのインストール</h3> - -<p>Raptor は、npmからインストールできる CLI (コマンドラインインターフェイス)ツールです。こうしてインストールできます:</p> - -<pre class="brush: bash language-html"><code class="language-bash">$ npm install -g @mozilla/raptor</code></pre> - -<p>インストールが完了したら、コマンドラインのraptorコマンドから実行できます:</p> - -<pre class="brush: bash language-html"><code class="language-bash">$ raptor --help</code></pre> - -<h4 id="もう一つのインストール">もう一つのインストール</h4> - -<p>Inpm が<code> /usr</code> や <code>/usr/local</code> ディレクトリへのグローバルパッケージとしてインストールする方法に不満がある場合、 いくつか別のオプションがあります:</p> - -<ol> - <li>npm のデフォルトディレクトリを別のディレクトリに変更する。<a href="https://docs.npmjs.com/getting-started/fixing-npm-permissions#option-2-change-npm-s-default-directory-to-another-directory">npmの手順に従うと</a>、npmがグローバルパッケージをインストールする場所を変更できて、ひょっとするとホームフォルダの特別なディレクトリに配置できます。</li> - <li>Raptor をローカルディレクトリにインストールして、相対的に参照します、例えば:</li> -</ol> - -<pre class="brush: bash language-html"><code class="language-bash">$ cd ~ -$ mkdir raptor-cli && cd raptor-cli -$ npm install @mozilla/raptor - -<strong># Elsewhere</strong> -$ ~/raptor-cli/node_modules/@mozilla/raptor/bin/raptor --help - -<strong># Symlink or add to aliases to save on verbosity</strong> -$ cd ~ -$ ln -s ~/raptor-cli/node_modules/@mozilla/raptor/bin/raptor raptor - -<strong># Now you can use it elsewhere</strong> -$ raptor --help</code></pre> - -<h3 id="プロファイルのインストール">プロファイルのインストール</h3> - -<p>In order to interact with the device in a predictable way, Raptor needs a few profile options and custom settings. The default <code>make</code> command for Raptor optimizes Gaia, disables FTU, enables User Timing to write to logcat, and resets Gaia.</p> - -<pre class="brush: bash language-html"><code class="language-bash"># Equivalent of: -# PERF_LOGGING=1 DEVICE_DEBUG=1 GAIA_OPTIMIZE=1 NOFTU=1 SCREEN_TIMEOUT=0 make reset-gaia -make raptor</code></pre> - -<p>If you already have a profile on your device, at a bare minimum you need the following profile options/settings set in order to use Raptor for performance testing:</p> - -<ul> - <li><code>PERF_LOGGING=1</code>, this sets <code>dom.performance.enable_user_timing_logging</code> in the profile to true.</li> - <li><code>NOFTU=1</code>, this disables the First-time experience, which is only needed if you are dealing with a freshly-reset Gaia.</li> - <li><code>SCREEN_TIMEOUT=0</code>, prevents the device from going to sleep and shutting off the screen.</li> - <li><code>NO_LOCKSCREEN=1</code>, removes the lock screen for easy application launching from the homescreen.</li> -</ul> - -<h3 id="コマンドラインインターフェイス">コマンドラインインターフェイス</h3> - -<p>Raptor provides a bit of helpful information right through the command line:</p> - -<pre class="brush: bash language-html"><code class="language-bash">$ raptor --help - -<strong>Usage:</strong> raptor <command> [options] - -command - test Run a performance test by name or path location. - submit Submit a Raptor metrics file to an InfluxDB database - -Options: - -v, --version outputs the raptor cli tool version - --config <path> specify additional Orangutan device configuration JSON. Environment: RAPTOR_CONFIG - --homescreen <origin> specify the origin or gaiamobile.org prefix of an application that is the device homescreen [verticalhome.gaiamobile.org] - --system <origin> specify the origin or gaiamobile.org prefix of an application that is the system application [system.gaiamobile.org] - --serial <serial> target a specific device for testing. Environment: ANDROID_SERIAL - --adb-host <host> connect to a device on a remote host. tip: use with --adb-port. Environment: ADB_HOST - --adb-port <port> set port for connecting to a device on a remote host. use with --adb-host. Environment: ADB_PORT - --marionette-host <host> <span class="blob-code-inner"><span class="pl-s">connect to marionette on a remote host. tip: use with --marionette-port. Envrionment: MARIONETTE_HOST - --marionette-port <port> set port for connecting to marionette on a remote host. tip: use with --marionette-host. Environment: MARIONETTE_PORT</span></span> - --forward-port <port> forward an adb port to the --marionette-port. [0] - --host <host> host for reporting metrics to InfluxDB database. Environment: RAPTOR_HOST [localhost] - --port <port> port for reporting metrics to InfluxDB database. Environment: RAPTOR_PORT [8086] - --username <username> username for reporting metrics to InfluxDB database. Environment: RAPTOR_USERNAME [root] - --password <password> password for reporting metrics to InfluxDB database. Environment: RAPTOR_PASSWORD [root] - --database <database> name of InfluxDB database for reporting metrics. Environment: RAPTOR_DATABASE - --protocol <protocol> Protocol used to connect to InfluxDB database for reporting metrics. Environment: RAPTOR_PROTOCOL [http] - --metrics <path> path to store historical test metrics. Environment: RAPTOR_METRICS - --output <mode> output mode: normal or quiet. Environment: RAPTOR_OUTPUT [normal] - --batch <count> batch database requests to <count> number of records [5000]</code></pre> - -<p>The core command to execute is the <code>test</code> command, which also has some helpful information:</p> - -<pre class="brush: bash language-html"><code class="language-bash">$ raptor test --help - -Usage: raptor test <nameOrPath> [options] - -nameOrPath named test or path to a particular test to run. Named tests: - coldlaunch cold-launch lifecycle of an application from appLaunch to fullyLoaded - reboot device reboot lifecycle from device power-on until System/Homescreen fullyLoaded - restart-b2g restart B2G lifecycle from B2G start until System/Homescreen fullyLoaded - -Options: - ... - --runs <runs> number of times to run the test and aggregate results [1] - --app <appOrigin> specify the origin or gaiamobile.org prefix of an application to test - --entry-point <entryPoint> specify an application entry point other than the default - --timeout <milliseconds> time to wait between runs for success to occur [60000] - --retries <times> times to retry test or run if failure or timeout occurs [1] - --launch-delay <milliseconds> time to wait between subsequent application launches [10000] - --memory-delay <milliseconds> time to wait before capturing memory after application fully loaded [0] - --script-timeout <milliseconds> time to wait when running scripts via marionette [10000] - --connection-timeout <milliseconds> marionette driver tcp connection timeout [2000] - --logcat <path> write the output from `adb logcat` to a file - --time <epochMilliseconds> override the start time and unique identifier for test runs</code></pre> - -<p>This should give us enough information to run our first performance test.</p> - -<h3 id="Running_a_performance_test">Running a performance test</h3> - -<p>Running a performance test consists of a few parts:</p> - -<ul> - <li>The raptor CLI command</li> - <li>A test to run, whether a named test or a path to a test</li> - <li>Any relevant test settings</li> -</ul> - -<p>For the most basic test, we can do a cold launch test against an application with a command like this:</p> - -<pre class="brush: bash language-html"><code class="language-bash">$ raptor test coldlaunch --app clock - -[Cold Launch: clock.gaiamobile.org] Preparing to start testing... -[Cold Launch: clock.gaiamobile.org] Priming application -[Cold Launch: clock.gaiamobile.org] Starting run 1 -[Cold Launch: clock.gaiamobile.org] Run 1 complete -[Cold Launch: clock.gaiamobile.org] Results from clock.gaiamobile.org - -| Metric | Mean | Median | Min | Max | StdDev | p95 | -| --------------------- | ------ | ------ | ------ | ------ | ------ | ------ | -| navigationLoaded | 939 | 939 | 939 | 939 | 0 | 939 | -| navigationInteractive | 1014 | 1014 | 1014 | 1014 | 0 | 1014 | -| visuallyLoaded | 1247 | 1247 | 1247 | 1247 | 0 | 1247 | -| contentInteractive | 1249 | 1249 | 1249 | 1249 | 0 | 1249 | -| fullyLoaded | 1250 | 1250 | 1250 | 1250 | 0 | 1250 | -| uss | 14.836 | 14.836 | 14.836 | 14.836 | 0 | 14.836 | -| pss | 19.137 | 19.137 | 19.137 | 19.137 | 0 | 19.137 | -| rss | 31.191 | 31.191 | 31.191 | 31.191 | 0 | 31.191 | - -[Cold Launch: clock.gaiamobile.org] Testing complete</code></pre> - -<p>During the cold launch test, you'll see B2G restart; the stated application will then launch once to prime it, and a second time to measure its performance. Looking at the log output above, you can see when each application run starts and stops. When a particular application has completed its testing, you will be given a table of metrics and testing will continue, if applicable. In the metrics table you'll see statistics for each performance entry captured during the lifespan of the test: mean (average), median, minimum value, maximum value, standard deviation, and 95th percentile.</p> - -<div class="note"> -<p><strong>Note</strong>: One fun fact is that the table produced by Raptor is compatible with GitHub-flavored Markdown.</p> -</div> - -<div class="note"> -<p><strong>Note:</strong> Standard deviation and 95th percentile need a collection of runs before they output statistically-useful data.</p> -</div> - -<p>All metrics relate to the name of the performance entry. The numbers gathered here are not just aggregations of the values produced by User Timing entries, so it's important to understand how these numbers are derived.</p> - -<h3 id="メトリクス集約">メトリクス集約</h3> - -<p>While Raptor relies on the User Timing API to gather its metrics, it also makes some assumptions about measurements that are different to what's expected in the context of normal web pages. In a typical web page, a performance marker represents the High-Resolution time from the moment of <code>navigationStart</code>. The User Timing API still captures this data, but Raptor's calculations also include additional time depending on the type of test running. Let's compare the creation of a performance marker in the context of a typical web page versus a Firefox OS application being cold launched.</p> - -<h4 id="典型的なwebページ">典型的なwebページ</h4> - -<p>In any web page, Firefox OS application or not, creating a performance marker with the User Timing API is simple:</p> - -<pre class="brush: js language-js"><code class="language-js">performance<span class="punctuation token">.</span><span class="function token">mark<span class="punctuation token">(</span></span><span class="string token">'hello'</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> - -<div style="top: 0px;" class="line-number"> </div> - -<p>Now let's get the value back and inspect its contents:</p> - -<pre class="brush: js language-js"><code class="language-js">performance<span class="punctuation token">.</span><span class="function token">getEntriesByType<span class="punctuation token">(</span></span><span class="string token">'mark'</span><span class="punctuation token">)</span><span class="punctuation token">[</span><span class="number token">0</span><span class="punctuation token">]</span><span class="punctuation token">;</span> -<span class="comment token"> -// returns the following object -</span>PerformanceMark <span class="punctuation token">{</span> name<span class="punctuation token">:</span> <span class="string token">"hello"</span><span class="punctuation token">,</span> entryType<span class="punctuation token">:</span> <span class="string token">"mark"</span><span class="punctuation token">,</span> startTime<span class="punctuation token">:</span> <span class="number token">5159.366323</span><span class="punctuation token">,</span> duration<span class="punctuation token">:</span> <span class="number token">0</span> <span class="punctuation token">}</span></code></pre> - -<div style="top: 0px;" class="line-number"> </div> - -<div style="top: 19px;" class="line-number"> </div> - -<div style="top: 38px;" class="line-number"> </div> - -<div style="top: 57px;" class="line-number"> </div> - -<p>Note the mark's <code>startTime</code> and <code>duration</code>. The <code>startTime</code> is nothing more than the high-resolution time elapsed since the time of <code>performance.timing.navigationStart</code>; in this case a little over 5,000 milliseconds. The duration is 0 because this represents a single point in time, which has no duration. The <code>startTime</code> simply states at what moment the marker was created. Inspecting the output of a performance marker is no different in Firefox OS.</p> - -<p>A performance measure on the other hand <em>does</em> include a duration, because it is the delta between two performance markers:</p> - -<pre class="brush: js language-js"><code class="language-js">performance<span class="punctuation token">.</span><span class="function token">mark<span class="punctuation token">(</span></span><span class="string token">'hello'</span><span class="punctuation token">)</span><span class="punctuation token">;</span> -performance<span class="punctuation token">.</span><span class="function token">mark<span class="punctuation token">(</span></span><span class="string token">'goodbye'</span><span class="punctuation token">)</span><span class="punctuation token">;</span> - -performance<span class="punctuation token">.</span><span class="function token">measure<span class="punctuation token">(</span></span><span class="string token">'greeting'</span><span class="punctuation token">,</span> <span class="string token">'hello'</span><span class="punctuation token">,</span> <span class="string token">'goodbye'</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> - -<div style="top: 57px;" class="line-number">Again, let's inspect the performance entry:</div> - -<pre class="brush: js language-js"><code class="language-js">performance<span class="punctuation token">.</span><span class="function token">getEntriesByType<span class="punctuation token">(</span></span><span class="string token">'measure'</span><span class="punctuation token">)</span><span class="punctuation token">[</span><span class="number token">0</span><span class="punctuation token">]</span><span class="punctuation token">;</span> -<span class="comment token"> -// returns the following object -</span>PerformanceMeasure <span class="punctuation token">{</span> name<span class="punctuation token">:</span> <span class="string token">"greeting"</span><span class="punctuation token">,</span> entryType<span class="punctuation token">:</span> <span class="string token">"measure"</span><span class="punctuation token">,</span> startTime<span class="punctuation token">:</span> <span class="number token">3528.523661</span><span class="punctuation token">,</span> duration<span class="punctuation token">:</span> <span class="number token">4183.291375999805</span> <span class="punctuation token">}</span></code></pre> - -<div style="top: 57px;" class="line-number">The duration is populated for performance measures, and in this example it took approximately 4.2 seconds to perform a <code>greeting</code>; going from <code>hello</code> to <code>goodbye</code>.</div> - -<h4 id="Raptor_コンテキスト">Raptor コンテキスト</h4> - -<p>The difference comes in the calculations that Raptor will report. Raptor makes an assumption that all markers generated are actually performance <em><strong>measures</strong></em> in reality, with their duration measured as the time between the application being instructed to launch and the marker being generated. For cold launch, the homescreen application (<code>gaia_grid</code> specifically) creates a special performance marker when an application is launching:</p> - -<pre class="brush: js language-js"><code class="language-js">performance<span class="punctuation token">.</span><span class="function token">mark<span class="punctuation token">(</span></span><span class="string token">'appLaunch@'</span> <span class="operator token">+</span> appOrigin<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> - -<div style="top: 0px;" class="line-number">In Raptor, performance markers can be given an <code>@-directive</code> that overrides the context of the marker. If the homescreen instead had invoked <code>performance.mark('appLaunch')</code>, normally we'd assume it is in the application's context. With an <code>@-directive</code> however we can key the performance marker to be against a different application, in essense creating a performance marker for one application inside another. This would evaluate to something like:</div> - -<pre class="brush: js language-js"><code class="language-js">performance<span class="punctuation token">.</span><span class="function token">mark<span class="punctuation token">(</span></span><span class="string token">'appLaunch@clock.gaiamobile.org'</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> - -<div style="top: 0px;" class="line-number">In this case the homescreen is generating a performance marker for the clock application denoting the time of <code>appLaunch</code>. Raptor will then calculate a delta between <code>appLaunch</code> and all performance markers to achieve a more accurate <em>user-perceived</em> time for a marker to be hit. By moving the moment of capture to earlier in the loading process, specifically as close to icon touch as possible, it makes the data between Raptor and camera-based measurements much more comparable.</div> - -<h3 id="テストを選択する">テストを選択する</h3> - -<p>Tests are selected by changing the name or file that Node.js executes. For example, to run the device reboot performance test instead of a cold launch test you'd do the following:</p> - -<pre class="brush: bash language-html"><code class="language-bash">$ raptor test reboot</code></pre> - -<p>More examples:</p> - -<pre class="brush: bash language-html"><code class="language-bash"><strong># Test Dialer cold launch</strong> -$ raptor test coldlaunch --app communications --entry-point dialer - -<strong># Change the number of runs</strong> -$ raptor test coldlaunch --app clock --runs 10 - -<strong># Introduce a 1-second delay before capturing memory</strong> -$ raptor test reboot --memory-delay 1000 - -<strong># Target a particular device</strong> -$ raptor test reboot --serial f30eccef -$ ANDROID_SERIAL=f30eccef raptor test reboot - -<strong># Turn on Raptor debug output, useful for bugs or problems -</strong>$ DEBUG=raptor:* raptor test reboot - -<strong># JSON mode, useful for post-processing of aggregate values</strong> -$ raptor test coldlaunch --app clock --output json - -<strong># Quiet mode, useful if you only care about the results</strong> -$ raptor test coldlaunch --app clock --output quiet</code></pre> - -<h2 id="テストを書く">テストを書く</h2> - -<p>While Raptor currently contains a few tests for running cold launch tests, rebooting, and restarting B2G, it is possible to write tests that run custom logic.</p> - -<p>We can inspect the contents of the current launch test to glean how we can write new tests.</p> - -<pre class="brush: js language-js"><code class="language-js"><span class="comment token">// mozilla-b2g/raptor -</span><span class="comment token">// tests/coldlaunch.js -</span> -<span class="function token">setup<span class="punctuation token">(</span></span><span class="keyword token">function</span><span class="punctuation token">(</span>options<span class="punctuation token">)</span> <span class="punctuation token">{</span> - options<span class="punctuation token">.</span>test <span class="operator token">=</span> <span class="string token">'cold-launch'</span><span class="punctuation token">;</span> - options<span class="punctuation token">.</span>phase <span class="operator token">=</span> <span class="string token">'cold-launch'</span><span class="punctuation token">;</span> -<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> - -<span class="function token">afterEach<span class="punctuation token">(</span></span><span class="keyword token">function</span><span class="punctuation token">(</span>phase<span class="punctuation token">)</span> <span class="punctuation token">{</span> - <span class="keyword token">return</span> phase<span class="punctuation token">.</span><span class="function token">closeApp<span class="punctuation token">(</span></span><span class="punctuation token">)</span><span class="punctuation token">;</span> -<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> - -<div style="top: 190px;" class="line-number">First comes setting up the test. In <code>setup</code>, pass a function to be executed, which will configure the test. This function will be passed all the current configuration settings. At a minimum, you will need the set the phase of the test, which determines the state the device is in when the test begins. Depending on which phase you select when setting options, you may need to pass additional information. For the launch test example, using the <code>cold</code> phase requires an application to be specified. This can either be set on the command line, or you can hard-code it via the <code>app</code> option to force the test to be specific to a certain app.</div> - -<div class="note"> -<p><strong>Note:</strong> If you hard-code the application to be launched, make you specify the origin host completely, e.g. "clock.gaiamobile.org". For entry-point-based apps, specify the <code>app</code> option and the <code>entryPoint</code> option.</p> -</div> - -<div class="warning"> -<p><strong>Important</strong>: Any test harness functions doing asynchronous work should return a Promise so Raptor can properly wait.</p> -</div> - -<p>The <code>afterEach()</code> function will be called once for each run after the phase has been started. For cold launch, it is after an application in context has been primed, exited, and re-opened, and the application denotes it is ready — i.e. <code>performance.mark('fullyLoaded')</code>. For reboot and B2G restart, the phase will be designated as ready when the System application and the Homescreen application are marked as fully loaded.</p> - -<p>The <code>phase</code> argument passed to <code>afterEach()</code> represents the current context instance of the phase test runner; in other words, it is specific to the current test being run. It contains methods and functionality that help you trigger device actions which will have profiled performance code. For example, you can start a Marionette.js session and trigger commands:</p> - -<pre class="brush: js language-js"><code class="language-js"><span class="function token">setup<span class="punctuation token">(</span></span><span class="keyword token">function</span><span class="punctuation token">(</span>options<span class="punctuation token">)</span> <span class="punctuation token">{</span> - options<span class="punctuation token">.</span>phase <span class="operator token">=</span> <span class="string token">'cold'</span><span class="punctuation token">;</span> -<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> - -<span class="function token">afterEach<span class="punctuation token">(</span></span><span class="keyword token">function</span><span class="punctuation token">(</span>phase<span class="punctuation token">)</span> <span class="punctuation token">{</span> - <span class="comment token"> // Note that returning a Promise denotes that we are done running the test -</span> <span class="keyword token">return</span> phase<span class="punctuation token">.</span>device<span class="punctuation token">.</span>marionette - <span class="punctuation token">.</span><span class="function token">startSession<span class="punctuation token">(</span></span><span class="punctuation token">)</span> - <span class="punctuation token">.</span><span class="function token">then<span class="punctuation token">(</span></span><span class="keyword token">function</span><span class="punctuation token">(</span>client<span class="punctuation token">)</span> <span class="punctuation token">{</span> - client<span class="punctuation token">.</span><span class="function token">executeScript<span class="punctuation token">(</span></span><span class="keyword token">function</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> - <span class="comment token"> // trigger code that captures the performance.measures created -</span> <span class="comment token"> // by the application being tested -</span> <span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> - client<span class="punctuation token">.</span><span class="function token">deleteSession<span class="punctuation token">(</span></span><span class="punctuation token">)</span><span class="punctuation token">;</span> - <span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> -<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> - -<div style="top: 285px;" class="line-number">The runner can also run a <code>teardown()</code> function when all tests are complete.</div> - -<pre class="brush: js language-js"><code class="language-js"><span class="function token">teardown<span class="punctuation token">(</span></span><span class="keyword token">function</span><span class="punctuation token">(</span>phase<span class="punctuation token">)</span> <span class="punctuation token">{</span> - <span class="keyword token">return</span> <span class="keyword token">new</span> <span class="class-name token">Promise</span><span class="punctuation token">(</span><span class="keyword token">function</span><span class="punctuation token">(</span>resolve<span class="punctuation token">)</span> <span class="punctuation token">{</span> - <span class="comment token"> // teardown the test, then resolve -</span> <span class="function token">resolve<span class="punctuation token">(</span></span><span class="punctuation token">)</span><span class="punctuation token">;</span> - <span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> -<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> - -<div style="top: 95px;" class="line-number">The Raptor Phase API has not yet been documented, so currently you'll need to <a href="https://github.com/mozilla-b2g/raptor/tree/master">read the source</a> for all the functionality available to you. It may be faster to <a href="https://developer.mozilla.org/ja/Firefox_OS/Platform/Testing/Raptor$edit#Support">seek help from a contributor</a> for help on getting started writing a particular test.</div> - -<h2 id="可視化と自動化">可視化と自動化</h2> - -<p>Raptor has improved tooling available for automation and visualization. The <code>test-perf</code> tool used to use the <a href="https://datazilla.mozilla.org/b2g/">Datazilla</a> tool for graphing and visualizing results to gain insight into possible regressions and performance pulse of applications. Raptor has moved away from Datazilla however for its visualization capabilities — for maintenance and usability reasons — instead having its own UI at <a href="https://raptor.mozilla.org/">https://raptor.mozilla.org</a>. The Raptor dashboards currently categorize performance metrics in a few key categories per device instance — measures and memory — with more metrics planned in the future.</p> - -<p>Raptor's front-end uses the <a href="http://grafana.org/">Grafana</a> visualization tool, and its backing store is <a href="http://influxdb.com/">InfluxDB</a>, a time series database. Grafana provides Raptor UI users with the ability to carry out custom drill-downs into charts, slice time as desired, view data point revisions, and build custom charts and data queries. The default view of several charts displays the 95th percentile of many metrics, but charts can be user-edited to graph other mathematical functions.</p> - -<p>This guide is not meant to be a tutorial on the usage of Grafana and InfluxDB, so to learn more about taking full advantage of the Raptor UI, read through these important pieces of documentation:</p> - -<ul> - <li><a href="http://docs.grafana.org/guides/gettingstarted/">Getting started with Grafana</a></li> - <li><a href="https://influxdb.com/docs/v0.9/query_language/functions.html">InfluxDB Aggregate Functions</a></li> -</ul> - -<h2 id="プライベートな可視化">プライベートな可視化</h2> - -<p>The Raptor dashboard visualization discussed in the previous section can also be installed and used privately. The installation is a Heroku-deployable environment for easy setup. It is also possible to run the Heroku application locally if you use Linux.</p> - -<p>To get started with private visualization, or want to learn more about its innards, see the repository: <a href="https://github.com/mozilla-b2g/raptor-dashboards">https://github.com/mozilla-b2g/raptor-dashboards</a>.</p> - -<p>You will also need an installation of InfluxDB 0.9.3+. You can learn more about installing it at: <a href="https://influxdb.com/docs/v0.9/introduction/installation.html">https://influxdb.com/docs/v0.9/introduction/installation.html</a>. Those who are familiar with Docker can also install InfluxDB from Docker Hub: <a href="https://hub.docker.com/r/tutum/influxdb/">https://hub.docker.com/r/tutum/influxdb/</a>.</p> - -<p>Raptor needs CLI options or environment variables for creating a connection to an InfluxDB database. It would be tedious to specify these continually on the command line, so to simplify this, you can export these environment variables from your shell, e.g. <code>~/.bashrc</code>, <code>~/.zshrc</code>, etc.</p> - -<pre class="brush: bash language-html"><code class="language-bash"># These settings will point to the installation and credentials of your InfluxDB instance: -export RAPTOR_HOST=localhost -export RAPTOR_USERNAME=root -export RAPTOR_PASSWORD=root -export RAPTOR_DATABASE=raptor -export RAPTOR_PROTOCOL=https -export RAPTOR_PORT=8086</code></pre> - -<p>In addition, Raptor's database schema requires its results to be tagged properly in order to display it in correct categories in its dashboard UI. Failure to have these properties set when running performance tests will cause the data to not be displayed. By default, you need to persist the memory configuration of the device, the device type, and the branch the performance test is based on. For example, if you are performance testing a KitKat-based Flame set to 319MB of memory and your patch is based off of Gaia's master branch, you will set the following properties via ADB:</p> - -<pre class="brush: bash language-html"><code class="language-bash">$ adb shell setprop persist.raptor.device flame-kk -$ adb shell setprop persist.raptor.memory 319 -$ adb shell setprop persist.raptor.branch master</code></pre> - -<div class="note"> -<p><strong>Note:</strong> If you are having trouble with the values being persisted or not saving at all, restart ADB as root with <code>adb root</code>.</p> -</div> - -<p>If you were working on a branch that was based off of v2.5 on an Aries with 2 Gigabytes of memory, you would use the following properties:</p> - -<pre class="brush: bash language-html"><code class="language-bash">$ adb shell setprop persist.raptor.device aries -$ adb shell setprop persist.raptor.memory 2048 -$ adb shell setprop persist.raptor.branch v2.5</code></pre> - -<div class="warning"> -<p><strong>Important</strong>: Currently visualization is highly-dependent on the existence of these persisted properties. They are only necessary when using the local visualization tooling; if you flash your device or otherwise unset these properties, you will need to re-set them in order to visualize performance metrics.</p> -</div> - -<p>Other than setting up the environment and device tags, Raptor can be run as normal locally. Upon each successful run, Raptor will report its metrics to the database. Once the test is complete, you can open a browser to your private visualization instance and view your own custom performance data.</p> - -<h2 id="必要に応じて動的にパフォーマンスマークを加える">必要に応じて動的にパフォーマンスマークを加える</h2> - -<p>One issue with Raptor is that since the tests require us to add performance marks into code, the Gaia codebase could quickly become littered with <code>Performance.mark()</code> calls without any meaningful relationship between them, making the code clutted and harder to understand. The best way to deal with this is to collect all the marks into some kind of patching files, and apply them dynamically as required when we want to run specific Raptor tests.</p> - -<p>To this end, Greg Weng has created a code transformer tool that will do just what is described above. The tool is currently a work in progress, but you can find more about it (including how to get it running) at this newsgroup entry: <a href="https://groups.google.com/forum/#%21topic/mozilla.dev.gaia/vBRUjSRLG6g">Raptor: code transformer + marionette workflow now is almost ready</a>. See also <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1181069" title="FIXED: [Build][Raptor] Add a code transformer tool to support dynamically adding marks to help to test app performance">バグ 1181069</a> for implementation specifics.</p> - -<p>We will publish more formal instructions once the tool has stabilised.</p> - -<h2 id="サポート">サポート</h2> - -<p>If you have questions about Raptor, visualization, or performance tooling in general, feel free to ping <code>:Eli</code> or <code>:rwood</code> in the #raptor channel on <a href="https://wiki.mozilla.org/IRC">Mozilla IRC</a>.</p> diff --git a/files/ja/archive/b2g_os/automated_testing/setting_up_marionette/index.html b/files/ja/archive/b2g_os/automated_testing/setting_up_marionette/index.html deleted file mode 100644 index 3076dde353..0000000000 --- a/files/ja/archive/b2g_os/automated_testing/setting_up_marionette/index.html +++ /dev/null @@ -1,48 +0,0 @@ ---- -title: Firefox OSのMarionetteの設定 -slug: Archive/B2G_OS/Automated_testing/Setting_up_Marionette -translation_of: 'https://marionette-client.readthedocs.io/en/latest/' ---- -<h2 id="Building_Firefox_OS_with_Marionette_enabled">Building Firefox OS with Marionette enabled</h2> -<p>Marionette's server component is part of gecko, and is compiled into a B2G build when ENABLE_MARIONETTE=1 is present in your mozconfig.</p> -<p><strong>For device builds</strong> (including the emulator), Marionette is enabled by default in all VARIANT=eng (engineering) builds. This is the default type of build created if you use ./config.sh <config>, ./build.sh. Marionette is not included in VARIANT=user builds, which is the type of build QA normally uses for testing.</p> -<p><strong>For B2G desktop builds</strong>, you'll need to add the line ENABLE_MARIONETTE=1 to your mozconfig before building.</p> -<h2 id="Setting_up_the_Marionette_client">Setting up the Marionette client</h2> -<p>The Marionette client is a Python package with which you can run Marionette tests. You'll need to set this up on your machine before using it.</p> -<p>To do so, you can either install it from pypi:</p> -<pre>$ pip install marionette_client</pre> -<p>Or from a gecko build tree:</p> -<pre>$ cd $GECKO_DIR/testing/marionette/client - -$ python setup.py develop</pre> -<p>You can perform these steps inside a virtualenv if you wish.</p> -<p>To verify Marionette is installed:</p> -<pre><code>$ python</code> - -<code>>>> from marionette import Marionette</code></pre> -<h2 id="Verifying_Marionette_is_running">Verifying Marionette is running</h2> -<h4 id="On_a_device">On a device</h4> -<p>Please make sure the [Settings > Device Information > More Information > Developer > Remote debugging] is OFF.</p> -<p>Connect your device to your computer and verify it appears in adb devices, then set up adb port forwarding to Marionette's port:</p> -<pre>$ adb devices -List of devices attached -full_unagi device - -$ adb forward tcp:2828 tcp:2828 - -$ telnet localhost 2828 -Trying 127.0.0.1... -Connected to localhost. -Escape character is '^]'. -66:{ - "from": "root", - "applicationType", "gecko", - "traits": [] -}</pre> -<p>If you see the above output, Marionette is running on your device.</p> -<h4 id="On_an_emulator">On an emulator</h4> -<p>Launch the emulator using the <code>./run-emulator.sh</code> script, then follow the above steps.</p> -<h4 id="On_a_B2G_desktop_build">On a B2G desktop build</h4> -<p>For desktop B2G builds, you need to add an additional pref in order for Marionette to successfully run: <code>marionette.force-local = true</code>. You can add this pref in gaia/profile/user.js as user_pref("marionette.force-local", true), then re-build your gaia profile before starting the B2G desktop build.</p> -<p>When using a B2G desktop build, you don't need to use adb port forwarding. After launching the build, telnetting to localhost 2828 should result in the same output shown above.</p> -<p> </p> diff --git a/files/ja/archive/b2g_os/automated_testing/xpcshell/index.html b/files/ja/archive/b2g_os/automated_testing/xpcshell/index.html deleted file mode 100644 index 3138b3394e..0000000000 --- a/files/ja/archive/b2g_os/automated_testing/xpcshell/index.html +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: XPCShell -slug: Archive/B2G_OS/Automated_testing/XPCShell -translation_of: Archive/B2G_OS/Automated_testing/XPCShell ---- -<div class="summary"> - <p><span class="seoSummary"><a href="/en-US/docs/Writing_xpcshell-based_unit_tests" title="/en-US/docs/Writing_xpcshell-based_unit_tests">XPCShellのテスト</a>はGecko XPCOM APIのヘッドレステストです。あなたはB2G上でXPCShellのテストを実行することができます; この記事の中でどのように実行するか書かれています。現在、これらは主にエミュレータ上でテストされており、しかしデバイス上でもうまく実行される理屈です。</span></p> -</div> -<div class="note"> - <p><strong>注意</strong>: この記事の<code>$B2G_HOME</code>はクローンしたB2Gリポジトリを指します。</p> -</div> -<h2 id="必須要件">必須要件</h2> -<ul> - <li>テスト対象をテストするためにB2Gをビルドする必要があります (参照: <a href="/ja/Firefox_OS/Building_and_installing_Firefox_OS" title="/ja/Firefox_OS/Building_and_installing_Firefox_OS">Firefox OS のビルドとインストール</a>)</li> - <li>いくつかのPythonパッケージ、virtualenvかそれ以外をインストールする必要があります: - <pre>pip install marionette_client</pre> - </li> - <li>requirements.txtファイルもまた利便性のために取り込むべきです: - <pre>wget people.mozilla.com/~ahalberstadt/runxpcshell-requirements.txt -pip install -r runxpcshell-requirements.txt -</pre> - </li> - <li><code>adb</code>をパスの通った場所に置くか<code>--adbpath</code>で指定 (Linux上では<code>$B2G_HOME/out/host/linux-x86/bin/adb</code>で見つかるでしょう) されているか確認します</li> - <li><a href="http://busybox.net/downloads/binaries/latest/busybox-armv6l">Busybox</a>のローカルコピーを持っていること (これは厳密には必要ではないがセットアップ時の要求を軽減する)</li> -</ul> -<h2 id="テストを実行する">テストを実行する</h2> -<p>以下のターミナルコマンドの中から一つを使ってxpcshellテストを実行することができます:</p> -<p>emulatorを使う場合:</p> -<pre>cd $B2G_HOME/objdir-gecko -make package-tests -cd dist/test-package-stage/xpcshell -python runtestsb2g.py --b2gpath $B2G_HOME --adbpath $ADB_PATH --emulator arm --use-device-libs --manifest <<a href="https://developer.mozilla.org/en-US/docs/Mozilla/QA/Writing_xpcshell-based_unit_tests#Adding_your_tests_to_the_xpcshell_manifest">path_to_xpcshell_manifest</a>> --testing-modules-dir <path_to_testing_modules_dir> --busybox <path_to_busybox_binary></pre> -<p>実機を使う場合:</p> -<pre>cd $B2G_HOME/objdir-gecko -make package-tests -cd dist/test-package-stage/xpcshell -python runtestsb2g.py --b2gpath $B2G_HOME --adbpath $ADB_PATH --use-device-libs --manifest <<a href="https://developer.mozilla.org/en-US/docs/Mozilla/QA/Writing_xpcshell-based_unit_tests#Adding_your_tests_to_the_xpcshell_manifest">path_to_xpcshell_manifest</a>> --testing-modules-dir <path_to_testing_modules_dir></pre> -<p>通常のデスクトップ用のxpcshellテストのように<code>--total-chunks</code> and <code>--this-chunks</code>オプションを加えることもできます:</p> -<pre>python runtestsb2g.py --help</pre> -<p>サポートする引数をすべてリストします。</p> -<p><code>runtestsb2g.py</code>を起動したあと、テストランナーがエミュレータを起動する (エミュレータ上でテストを実行する場合) かデバイスを再起動する (デバイス上でテストを実行する場合) でしょう、そしてテストを実行開始します。なぜならばエミュレータは遅く、テストプロファイルをプッシュし、B2Gを再起動する必要があり、テストは開始に数分かかります。</p> -<p>テスト終了時、エミュレータはシャットダウンします。実機の場合再起動します。</p> -<h3 id="busyboxの手動インストール">busyboxの手動インストール</h3> -<p>デバイス上でxpcshellテストを実行するときは<code>--busybox</code>はいりません。そのようなテスト実行のセットアップはとても時間がかかります。幸いにもテストを実行する前に手動でインストールできます。手動インストールの例は<a href="https://github.com/mozilla/Negatus/blob/master/setup-tools.sh" title="https://github.com/mozilla/Negatus/blob/master/setup-tools.sh">https://github.com/mozilla/Negatus/blob/master/setup-tools.sh</a>をご覧ください。</p> -<h2 id="エミュレータをダウンロードしてxpcshellテストの実行">エミュレータをダウンロードしてxpcshellテストの実行</h2> -<p>もし違うコンフィグ (otoroのような) でB2Gをビルドしてエミュレータ上でテストを実行したいなら、あなた自身がエミュレータをビルドすることなくテストを実行することができます。 <code>runreftestb2g.py</code>と<code>--b2gpath /path/to/unpacked/emulator</code>の代わりに<code>--b2gpath $B2G_HOME</code>引数を置き換えた上記と同じ命令を使って、最新のtrunkのarmエミュレータをダウンロードします。</p> |
