mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 942288 - Test for HomeProvider.jsm. r=mcomella
This commit is contained in:
parent
3eeb5535fc
commit
6b9cbb48e5
@ -39,6 +39,7 @@ skip-if = processor == "x86"
|
||||
[testJarReader]
|
||||
[testLinkContextMenu]
|
||||
[testHomeListsProvider]
|
||||
[testHomeProvider]
|
||||
[testLoad]
|
||||
[testMailToContextMenu]
|
||||
[testMasterPassword]
|
||||
|
9
mobile/android/base/tests/testHomeProvider.java
Normal file
9
mobile/android/base/tests/testHomeProvider.java
Normal file
@ -0,0 +1,9 @@
|
||||
package org.mozilla.gecko.tests;
|
||||
|
||||
import org.mozilla.gecko.*;
|
||||
|
||||
public class testHomeProvider extends JavascriptTest {
|
||||
public testHomeProvider() {
|
||||
super("testHomeProvider.js");
|
||||
}
|
||||
}
|
45
mobile/android/base/tests/testHomeProvider.js
Normal file
45
mobile/android/base/tests/testHomeProvider.js
Normal file
@ -0,0 +1,45 @@
|
||||
// -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const { utils: Cu } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/HomeProvider.jsm");
|
||||
Cu.import("resource://gre/modules/osfile.jsm");
|
||||
Cu.import("resource://gre/modules/Sqlite.jsm");
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
|
||||
const TEST_DATASET_ID = "test-dataset-id";
|
||||
const TEST_URL = "http://test.com";
|
||||
|
||||
const DB_PATH = OS.Path.join(OS.Constants.Path.profileDir, "home.sqlite");
|
||||
|
||||
add_task(function test_save_and_delete() {
|
||||
// Use the HomeProvider API to save some data.
|
||||
let storage = HomeProvider.getStorage(TEST_DATASET_ID);
|
||||
yield storage.save([{ url: TEST_URL }]);
|
||||
|
||||
// Peek in the DB to make sure we have the right data.
|
||||
let db = yield Sqlite.openConnection({ path: DB_PATH });
|
||||
|
||||
// Make sure the items table was created.
|
||||
do_check_true(yield db.tableExists("items"));
|
||||
|
||||
// Make sure the correct values for the item ended up in there.
|
||||
let result = yield db.execute("SELECT * FROM items", null, function onRow(row){
|
||||
do_check_eq(row.getResultByName("dataset_id"), TEST_DATASET_ID);
|
||||
do_check_eq(row.getResultByName("url"), TEST_URL);
|
||||
});
|
||||
|
||||
// Use the HomeProvider API to delete the data.
|
||||
yield storage.deleteAll();
|
||||
|
||||
// Make sure the data was deleted.
|
||||
let result = yield db.execute("SELECT * FROM items");
|
||||
do_check_eq(result.length, 0);
|
||||
|
||||
db.close();
|
||||
});
|
||||
|
||||
run_next_test();
|
Loading…
Reference in New Issue
Block a user