You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by zh...@apache.org on 2008/06/09 00:20:59 UTC

svn commit: r664568 - in /incubator/shindig/trunk/features: core/prefstest.js pom.xml

Author: zhen
Date: Sun Jun  8 15:20:59 2008
New Revision: 664568

URL: http://svn.apache.org/viewvc?rev=664568&view=rev
Log:
Applied Shreyas Desai's patch for gadgets.Prefs unittests. (SHINDIG-336)


Added:
    incubator/shindig/trunk/features/core/prefstest.js
Modified:
    incubator/shindig/trunk/features/pom.xml

Added: incubator/shindig/trunk/features/core/prefstest.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/features/core/prefstest.js?rev=664568&view=auto
==============================================================================
--- incubator/shindig/trunk/features/core/prefstest.js (added)
+++ incubator/shindig/trunk/features/core/prefstest.js Sun Jun  8 15:20:59 2008
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @fileoverview
+ *
+ * Unittests for gadgets.prefs.
+ * TODO cover more gadgets.prefs functions.
+ */
+
+function PrefsTest(name) {
+  TestCase.call(this, name);
+}
+
+PrefsTest.inherits(TestCase);
+
+PrefsTest.prototype.setUp = function() {
+  this.params = {myCounter: 100, myString: '15.3', myUndefined: undefined,
+      myObject: {}, myFloat: 3.3, myBool: true, myArray: ['one', 'two'],
+      boolString: 'true'};
+};
+
+PrefsTest.prototype.tearDown = function() {
+  this.params = undefined;
+};
+
+PrefsTest.prototype.testGetInt = function() {
+    var expectedResults = {myCounter: 100, myString: 15, myUndefined: 0,
+        myObject: 0, myFloat: 3};
+
+    var pref = new gadgets.Prefs();
+
+    gadgets.Prefs.setInternal_(this.params, 100);
+
+    for (var userPref in expectedResults) {
+      this.assertEquals(expectedResults[userPref], pref.getInt(userPref));
+    }
+};
+
+PrefsTest.prototype.testGetFloat = function() {
+    var expectedResults = {myCounter: 100, myString: 15.3, myUndefined: 0,
+        myObject: 0, myFloat: 3.3};
+
+    var pref = new gadgets.Prefs();
+
+    gadgets.Prefs.setInternal_(this.params, 100);
+
+    for (var userPref in expectedResults) {
+      this.assertEquals(expectedResults[userPref], pref.getFloat(userPref));
+    }
+};
+
+PrefsTest.prototype.testGetBool = function() {
+    var expectedResults = {myCounter: true, myString: true, myUndefined: false,
+        myObject: false, myFloat: true, myBool: true, boolString: true,
+        myArray: false};
+
+    var pref = new gadgets.Prefs();
+
+    gadgets.Prefs.setInternal_(this.params, 100);
+
+    for (var userPref in expectedResults) {
+      this.assertEquals(expectedResults[userPref], pref.getBool(userPref));
+    }
+};
+

Modified: incubator/shindig/trunk/features/pom.xml
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/features/pom.xml?rev=664568&r1=664567&r2=664568&view=diff
==============================================================================
--- incubator/shindig/trunk/features/pom.xml (original)
+++ incubator/shindig/trunk/features/pom.xml Sun Jun  8 15:20:59 2008
@@ -89,6 +89,7 @@
                   <source>mockenv.js</source>
                   <source>core/auth.js</source>
                   <source>core/util.js</source>
+                  <source>core/prefs.js</source>
                   <source>opensocial-reference/opensocial.js</source>
                   <source>opensocial-reference/activity.js</source>
                   <source>opensocial-reference/address.js</source>