test_bug6514.js
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
31 function runTest () {
32 
33  var dbq = Cc["@songbirdnest.com/Songbird/DatabaseQuery;1"]
34  .createInstance(Ci.sbIDatabaseQuery);
35 
36  var ios = Cc["@mozilla.org/network/io-service;1"]
37  .createInstance(Ci.nsIIOService);
38 
39  var dir = Cc["@mozilla.org/file/directory_service;1"]
40  .createInstance(Ci.nsIProperties);
41 
42  var testdir = dir.get("ProfD", Ci.nsIFile);
43 
44  var actualdir = testdir.clone();
45  actualdir.append("db_tests");
46 
47  if(!actualdir.exists())
48  {
49  try {
50  actualdir.create(Ci.nsIFile.DIRECTORY_TYPE, 0700);
51  } catch(e) {
52  //Some failures might be handled later. Some might be ignored.
53  throw e;
54  }
55  }
56 
57  var uri = ios.newFileURI(actualdir);
58  dbq.databaseLocation = uri;
59 
60  assertEqual(dbq.databaseLocation.spec, uri.spec);
61 
62  // clear the table first and then re-create
63  dbq.setDatabaseGUID("test_sync");
64  dbq.addQuery("drop table proxy_test");
65  dbq.addQuery("create table proxy_test (name text, value text)");
66  dbq.execute();
67  dbq.waitForCompletion();
68  dbq.resetQuery();
69 
70  for ( var j = 0; j < 500; j++ ) {
71  log("Looping: doing query number: " + j);
72  var query = Cc["@songbirdnest.com/Songbird/DatabaseQuery;1"]
73  .createInstance(Ci.sbIDatabaseQuery);
74  query.databaseLocation = uri;
75  query.setDatabaseGUID("test_sync");
76 
77  for ( var i = 0; i < 10; i++ ) {
78  query.addQuery("insert into proxy_test values ('test " + j + i + "', 'testing... " + j + i + "')");
79  }
80 
81  query.execute();
82  }
83 
84  return Components.results.NS_OK;
85 }
86 
const Cc
function log(s)
function assertEqual(aExpected, aActual, aMessage)
function runTest()
Test file.
Definition: test_bug6514.js:31
var uri
Definition: FeedWriter.js:1135
const Ci
var ios
Definition: head_feeds.js:5
_getSelectedPageStyle s i