Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Unified Diff: remoting/webapp/base/js/base_inherits_unittest.js

Issue 1016373003: [Chromoting] Change Application.Delegate to proper subclass of Application. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync/merge Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/webapp/base/js/application.js ('k') | remoting/webapp/browser_test/bump_scroll_browser_test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/base/js/base_inherits_unittest.js
diff --git a/remoting/webapp/base/js/base_inherits_unittest.js b/remoting/webapp/base/js/base_inherits_unittest.js
index bda316b576905ec218e244d779defbee71a13c31..baa5b6f7e8e7518c2d1ee29ac500ec3e5657d67b 100644
--- a/remoting/webapp/base/js/base_inherits_unittest.js
+++ b/remoting/webapp/base/js/base_inherits_unittest.js
@@ -17,9 +17,12 @@ var GrandChildClass = function() {
this.name = 'grandChild';
}
-/** @return {string} */
-GrandChildClass.prototype.overrideMethod = function() {
- return 'overrideMethod - grandChild';
+/**
+ * @param {string} arg
+ * @return {string}
+ */
+GrandChildClass.prototype.overrideMethod = function(arg) {
+ return 'overrideMethod - grandChild - ' + arg;
}
/**
@@ -32,9 +35,12 @@ var ChildClass = function() {
this.childOnly = 'childOnly';
}
-/** @return {string} */
-ChildClass.prototype.overrideMethod = function() {
- return 'overrideMethod - child';
+/**
+ * @param {string} arg
+ * @return {string}
+ */
+ChildClass.prototype.overrideMethod = function(arg) {
+ return 'overrideMethod - child - ' + arg;
}
/** @return {string} */
@@ -43,8 +49,8 @@ ChildClass.prototype.childMethod = function() {
}
/**
- * @constructor
* @param {string} arg
+ * @constructor
*/
var ParentClass = function(arg) {
/** @type {string} */
@@ -60,9 +66,12 @@ ParentClass.prototype.parentMethod = function() {
return 'parentMethod';
}
-/** @return {string} */
-ParentClass.prototype.overrideMethod = function() {
- return 'overrideMethod - parent';
+/**
+ * @param {string} arg
+ * @return {string}
+ */
+ParentClass.prototype.overrideMethod = function(arg) {
+ return 'overrideMethod - parent - ' + arg;
}
QUnit.test('should invoke parent constructor with the correct arguments',
@@ -90,19 +99,33 @@ QUnit.test('should preserve instanceof', function(assert) {
QUnit.test('should override parent property and method', function(assert) {
var child = new ChildClass();
assert.equal(child.name, 'child');
- assert.equal(child.overrideMethod(), 'overrideMethod - child');
+ assert.equal(child.overrideMethod('123'), 'overrideMethod - child - 123');
assert.equal(child.childOnly, 'childOnly');
assert.equal(child.childMethod(), 'childMethod');
});
-QUnit.test('should works on an inheritance chain', function(assert) {
+QUnit.test('should work on an inheritance chain', function(assert) {
var grandChild = new GrandChildClass();
assert.equal(grandChild.name, 'grandChild');
- assert.equal(grandChild.overrideMethod(), 'overrideMethod - grandChild');
+ assert.equal(grandChild.overrideMethod('246'),
+ 'overrideMethod - grandChild - 246');
assert.equal(grandChild.childOnly, 'childOnly');
assert.equal(grandChild.childMethod(), 'childMethod');
assert.equal(grandChild.parentOnly, 'parentOnly');
assert.equal(grandChild.parentMethod(), 'parentMethod');
});
-})();
+QUnit.test('should be able to access parent class methods', function(assert) {
+ var grandChild = new GrandChildClass();
+
+ assert.equal(grandChild.overrideMethod('789'),
+ 'overrideMethod - grandChild - 789');
+
+ var childMethod = ChildClass.prototype.overrideMethod.call(grandChild, '81');
+ assert.equal(childMethod, 'overrideMethod - child - 81');
+
+ var parentMethod = ParentClass.prototype.overrideMethod.call(grandChild, '4');
+ assert.equal(parentMethod, 'overrideMethod - parent - 4');
+});
+
+})();
« no previous file with comments | « remoting/webapp/base/js/application.js ('k') | remoting/webapp/browser_test/bump_scroll_browser_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698