test_nullresultvalue.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  dbq.setDatabaseGUID("test_nullresultvalue");
63  dbq.addQuery("drop table nullresultvalue_test");
64  dbq.addQuery("create table nullresultvalue_test (name text, value text)");
65  dbq.addQuery("insert into nullresultvalue_test values('test 0', null)");
66  dbq.addQuery("insert into nullresultvalue_test values(NULL, 'testing... 1')");
67  dbq.addQuery("insert into nullresultvalue_test values(NULL, NULL)");
68 
69  dbq.execute();
70  dbq.waitForCompletion();
71  dbq.resetQuery();
72 
73  dbq.addQuery("select * from nullresultvalue_test");
74  dbq.execute();
75  dbq.waitForCompletion();
76 
77  var dbr = dbq.getResultObject();
78 
79  var rowCount = dbr.getRowCount();
80  assertEqual(rowCount, 3);
81 
82  var val = dbr.getRowCell(0, 0);
83  assertEqual(val, "test 0");
84 
85  val = dbr.getRowCell(0, 1);
86  assertEqual(val, null);
87 
88  val = dbr.getRowCell(1, 0);
89  assertEqual(val, null);
90 
91  val = dbr.getRowCell(1, 1);
92  assertEqual(val, "testing... 1");
93 
94  val = dbr.getRowCell(2, 0);
95  assertEqual(val, null);
96 
97  val = dbr.getRowCell(2, 1);
98  assertEqual(val, null);
99 
100  return Components.results.NS_OK;
101 }
102 
const Cc
function assertEqual(aExpected, aActual, aMessage)
this _dialogInput val(dateText)
return null
Definition: FeedWriter.js:1143
var uri
Definition: FeedWriter.js:1135
const Ci
var ios
Definition: head_feeds.js:5
function runTest()
Test file.