Chromium Code Reviews

Side by Side Diff: chrome/test/data/extensions/api_test/README.txt

Issue 199074: Don't allow updating tabs to javascript URLs without host (Closed)
Patch Set: Remove unchanged file Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
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 25 matching lines...)
36 chrome.bookmarks.getTree(chrome.test.callbackPass(function(results) { 36 chrome.bookmarks.getTree(chrome.test.callbackPass(function(results) {
37 chrome.test.assertTrue(compareTrees(results, expected), 37 chrome.test.assertTrue(compareTrees(results, expected),
38 "getTree() result != expected"); 38 "getTree() result != expected");
39 })); 39 }));
40 }, 40 },
41 41
42 function get() { 42 function get() {
43 chrome.bookmarks.get("1", chrome.test.callbackPass(function(results) { 43 chrome.bookmarks.get("1", chrome.test.callbackPass(function(results) {
44 chrome.test.assertTrue(compareNode(results[0], expected[0].children[0])); 44 chrome.test.assertTrue(compareNode(results[0], expected[0].children[0]));
45 })); 45 }));
46 chrome.bookmarks.get("42", chrome.test.callbackFail(function(){}, "Can't fin d bookmark for id.")); 46 chrome.bookmarks.get("42", chrome.test.callbackFail("Can't find bookmark for id."));
47 }, 47 },
48 48
49 function getArray() { 49 function getArray() {
50 chrome.bookmarks.get(["1", "2"], chrome.test.callbackPass(function(results) { 50 chrome.bookmarks.get(["1", "2"], chrome.test.callbackPass(function(results) {
51 chrome.test.assertTrue(compareNode(results[0], expected[0].children[0]), 51 chrome.test.assertTrue(compareNode(results[0], expected[0].children[0]),
52 "get() result != expected"); 52 "get() result != expected");
53 chrome.test.assertTrue(compareNode(results[1], expected[0].children[1]), 53 chrome.test.assertTrue(compareNode(results[1], expected[0].children[1]),
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 a second argument which is the error 62 Note that chrome.test.callbackFail takes an argument which is the error message
63 message that it expects to get when the callback fails (chrome.extension.lastErr or.message). 63 that it expects to get when the callback fails
64 (chrome.extension.lastError.message).
64 65
65 Here's what the output of this test might look like: 66 Here's what the output of this test might look like:
66 [==========] Running 1 test from 1 test case. 67 [==========] Running 1 test from 1 test case.
67 [----------] Global test environment set-up. 68 [----------] Global test environment set-up.
68 [----------] 1 test from ExtensionApiTest 69 [----------] 1 test from ExtensionApiTest
69 [ RUN ] ExtensionApiTest.Bookmarks 70 [ RUN ] ExtensionApiTest.Bookmarks
70 ( RUN ) getTree 71 ( RUN ) getTree
71 ( SUCCESS ) 72 ( SUCCESS )
72 ( RUN ) get 73 ( RUN ) get
73 ( SUCCESS ) 74 ( SUCCESS )
74 ( RUN ) getArray 75 ( RUN ) getArray
75 ( SUCCESS ) 76 ( SUCCESS )
76 Got EXTENSION_TEST_PASSED notification. 77 Got EXTENSION_TEST_PASSED notification.
77 [ OK ] ExtensionApiTest.DISABLED_Bookmarks (2472 ms) 78 [ OK ] ExtensionApiTest.DISABLED_Bookmarks (2472 ms)
78 [----------] 1 test from ExtensionApiTest (2475 ms total) 79 [----------] 1 test from ExtensionApiTest (2475 ms total)
79 80
80 [----------] Global test environment tear-down 81 [----------] Global test environment tear-down
81 [==========] 1 test from 1 test case ran. (2482 ms total) 82 [==========] 1 test from 1 test case ran. (2482 ms total)
82 [ PASSED ] 1 test. 83 [ PASSED ] 1 test.
83 1 test run 84 1 test run
84 0 test failed 85 0 test failed
85 86
86 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
87 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
88 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).
OLDNEW

Powered by Google App Engine