| OLD | NEW |
| 1 This directory contains extensions which are unit tests for the extension API. | 1 This directory contains extensions which are unit tests for the extension API. |
| 2 These tests are written using the extension API test framework, which allows | 2 These tests are written using the extension API test framework, which allows |
| 3 us to do end-to-end testing of extension API in a browser_test. The general way | 3 us to do end-to-end testing of extension API in a browser_test. The general way |
| 4 these tests work is to run code in an extension when they're loaded and to post | 4 these tests work is to run code in an extension when they're loaded and to post |
| 5 a pass or fail notification back up to the C++ unit test which then reports the | 5 a pass or fail notification back up to the C++ unit test which then reports the |
| 6 success or failure. In the common case, the extension runs many subtests and | 6 success or failure. In the common case, the extension runs many subtests and |
| 7 then reports up a single pass or fail. This case is made easy by the test | 7 then reports up a single pass or fail. This case is made easy by the test |
| 8 framework. | 8 framework. |
| 9 | 9 |
| 10 To write a new test: | 10 To write a new test: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 "get() result != expected"); | 54 "get() result != expected"); |
| 55 })); | 55 })); |
| 56 } | 56 } |
| 57 ]); | 57 ]); |
| 58 | 58 |
| 59 // compareNode and compareTrees are helper functions that the bookmarks test | 59 // compareNode and compareTrees are helper functions that the bookmarks test |
| 60 // uses for convenience. They're not really relevant to the framework itself. | 60 // uses for convenience. They're not really relevant to the framework itself. |
| 61 | 61 |
| 62 Note that chrome.test.callbackFail takes an argument which is the error message | 62 Note that chrome.test.callbackFail takes an argument which is the error message |
| 63 that it expects to get when the callback fails | 63 that it expects to get when the callback fails |
| 64 (chrome.extension.lastError.message). | 64 (chrome.runtime.lastError.message). |
| 65 | 65 |
| 66 Here's what the output of this test might look like: | 66 Here's what the output of this test might look like: |
| 67 [==========] Running 1 test from 1 test case. | 67 [==========] Running 1 test from 1 test case. |
| 68 [----------] Global test environment set-up. | 68 [----------] Global test environment set-up. |
| 69 [----------] 1 test from ExtensionApiTest | 69 [----------] 1 test from ExtensionApiTest |
| 70 [ RUN ] ExtensionApiTest.Bookmarks | 70 [ RUN ] ExtensionApiTest.Bookmarks |
| 71 ( RUN ) getTree | 71 ( RUN ) getTree |
| 72 ( SUCCESS ) | 72 ( SUCCESS ) |
| 73 ( RUN ) get | 73 ( RUN ) get |
| 74 ( SUCCESS ) | 74 ( SUCCESS ) |
| 75 ( RUN ) getArray | 75 ( RUN ) getArray |
| 76 ( SUCCESS ) | 76 ( SUCCESS ) |
| 77 Got EXTENSION_TEST_PASSED notification. | 77 Got EXTENSION_TEST_PASSED notification. |
| 78 [ OK ] ExtensionApiTest.DISABLED_Bookmarks (2472 ms) | 78 [ OK ] ExtensionApiTest.DISABLED_Bookmarks (2472 ms) |
| 79 [----------] 1 test from ExtensionApiTest (2475 ms total) | 79 [----------] 1 test from ExtensionApiTest (2475 ms total) |
| 80 | 80 |
| 81 [----------] Global test environment tear-down | 81 [----------] Global test environment tear-down |
| 82 [==========] 1 test from 1 test case ran. (2482 ms total) | 82 [==========] 1 test from 1 test case ran. (2482 ms total) |
| 83 [ PASSED ] 1 test. | 83 [ PASSED ] 1 test. |
| 84 1 test run | 84 1 test run |
| 85 0 test failed | 85 0 test failed |
| 86 | 86 |
| 87 Note the RUN/SUCCESS messages in () - these are the subtests that are run in | 87 Note the RUN/SUCCESS messages in () - these are the subtests that are run in |
| 88 the extension itself. Anything printed with chrome.test.log() will also display | 88 the extension itself. Anything printed with chrome.test.log() will also display |
| 89 in stdout of the browser test (and hence in the buildbot output for that test). | 89 in stdout of the browser test (and hence in the buildbot output for that test). |
| OLD | NEW |