зеркало из https://github.com/mozilla/pjs.git
Bug 554133: Test that total search results returned is correct. r=dtownsend
This commit is contained in:
Родитель
1af482ca7b
Коммит
d392081f4a
|
@ -0,0 +1,282 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<searchresults total_results="100">
|
||||
<addon>
|
||||
<name>PASS</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test1@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test sumary</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install>http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test2@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Should not return an incompatible add-on</summary>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>2</min_version>
|
||||
<max_version>2</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test3@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test sumary</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install>http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test4@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Should not return an add-on for a different OS</summary>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<learnmore>https://addons.mozilla.org/addon/5992</learnmore>
|
||||
<install os="Windows" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test5@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>
|
||||
This should work fine
|
||||
</summary>
|
||||
<description>
|
||||
Test description
|
||||
</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<learnmore>
|
||||
https://addons.mozilla.org/addon/5992
|
||||
</learnmore>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">
|
||||
http://localhost:4444/test.xpi
|
||||
</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test5@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Should not include the same result twice</summary>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<learnmore>https://addons.mozilla.org/addon/5992</learnmore>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS</name>
|
||||
<type id='2'>Theme</type>
|
||||
<guid>test6@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<rating>4</rating>
|
||||
<summary>Specific OS should work fine</summary>
|
||||
<eula>EULA should be confirmed</eula>
|
||||
<thumbnail>
|
||||
http://localhost:4444/test_bug404024/thumbnail.png
|
||||
</thumbnail>
|
||||
<icon>
|
||||
http://localhost:4444/test_bug404024/icon.png
|
||||
</icon>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<install os="Windows">
|
||||
http://localhost:4444/test.xpi
|
||||
</install>
|
||||
<install os="XPCShell">
|
||||
http://localhost:4444/XPCShell.xpi
|
||||
</install>
|
||||
<install os="Darwin">
|
||||
http://localhost:4444/test.xpi
|
||||
</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test7@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test sumary</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install>http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test8@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test sumary</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install>http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test9@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test sumary</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install>http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test10@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test sumary</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install>http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test11@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test sumary</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install>http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>test12@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test sumary</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<application_id>1</application_id>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install>http://localhost:4444/test.xpi</install>
|
||||
</addon>
|
||||
</searchresults>
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// This verifies that if the AMO response provides total_results,
|
||||
// searchSucceeded is called with the correct number of total results
|
||||
|
||||
Components.utils.import("resource://gre/modules/AddonRepository.jsm");
|
||||
|
||||
const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url";
|
||||
|
||||
do_load_httpd_js();
|
||||
var server;
|
||||
|
||||
var TESTS = [
|
||||
{
|
||||
query: "bug554133",
|
||||
maxResults: 2,
|
||||
length: 2,
|
||||
total: 100
|
||||
},
|
||||
{
|
||||
query: "bug554133",
|
||||
maxResults: 10,
|
||||
length: 10,
|
||||
total: 100
|
||||
},
|
||||
{
|
||||
query: "bug554133",
|
||||
maxResults: 100,
|
||||
length: 10,
|
||||
total: 100
|
||||
}
|
||||
];
|
||||
|
||||
var gCurrentTest = 0;
|
||||
var SearchCallback = {
|
||||
searchSucceeded: function(addons, length, total) {
|
||||
do_check_false(AddonRepository.isSearching);
|
||||
do_check_eq(addons.length, length);
|
||||
do_check_eq(length, TESTS[gCurrentTest].length);
|
||||
do_check_eq(total, TESTS[gCurrentTest].total);
|
||||
|
||||
gCurrentTest++;
|
||||
run_current_test();
|
||||
},
|
||||
|
||||
searchFailed: function() {
|
||||
server.stop(do_test_finished);
|
||||
do_throw("Search results failed");
|
||||
}
|
||||
};
|
||||
|
||||
function run_current_test() {
|
||||
if (gCurrentTest < TESTS.length) {
|
||||
var query = TESTS[gCurrentTest].query;
|
||||
var maxResults = TESTS[gCurrentTest].maxResults;
|
||||
AddonRepository.searchAddons(query, maxResults, SearchCallback);
|
||||
}
|
||||
else
|
||||
server.stop(do_test_finished);
|
||||
}
|
||||
|
||||
function run_test()
|
||||
{
|
||||
// Setup for test
|
||||
do_test_pending();
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
|
||||
|
||||
startupManager();
|
||||
|
||||
server = new nsHttpServer();
|
||||
server.registerDirectory("/", do_get_file("data"));
|
||||
server.start(4444);
|
||||
|
||||
// Point search to the test server
|
||||
Services.prefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, "http://localhost:4444/test_%TERMS%.xml");
|
||||
|
||||
do_check_neq(AddonRepository, null);
|
||||
gCurrentTest = 0;
|
||||
run_current_test();
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче