1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3
* ***** BEGIN LICENSE BLOCK *****
4
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
6
* The contents of this file are subject to the Mozilla Public License Version
7
* 1.1 (the "License"); you may not use this file except in compliance with
8
* the License. You may obtain a copy of the License at
9
* http://www.mozilla.org/MPL/
11
* Software distributed under the License is distributed on an "AS IS" basis,
12
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
* for the specific language governing rights and limitations under the
16
* The Original Code is Mozilla Communicator client code, released
19
* The Initial Developer of the Original Code is
20
* Netscape Communications Corporation.
21
* Portions created by the Initial Developer are Copyright (C) 1998
22
* the Initial Developer. All Rights Reserved.
26
* Alternatively, the contents of this file may be used under the terms of
27
* either of the GNU General Public License Version 2 or later (the "GPL"),
28
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29
* in which case the provisions of the GPL or the LGPL are applicable instead
30
* of those above. If you wish to allow use of your version of this file only
31
* under the terms of either the GPL or the LGPL, and not to allow others to
32
* use your version of this file under the terms of the MPL, indicate your
33
* decision by deleting the provisions above and replace them with the notice
34
* and other provisions required by the GPL or the LGPL. If you do not delete
35
* the provisions above, a recipient may use your version of this file under
36
* the terms of any one of the MPL, the GPL or the LGPL.
38
* ***** END LICENSE BLOCK ***** */
41
* Test classes that inherit from multiple interfaces. This differs
42
* from classes that inherit from interfaces other than nsISupports,
43
* in that you can't have an object with all the
45
* See xpctest_multiple.idl and xpctest_multiple.cpp.
48
StartTest( "Classes that inherit from multiple interfaces" );
53
function SetupTest() {
55
// xpcTestChild2 inherits from nsIXPCTestChild2 nsIXPCTestParentOne,
56
// and nsIXPCTestParentTwo but implements all the interfaces itself
58
iChild = Components.interfaces.nsIXPCTestChild2;
59
iParentOne = Components.interfaces.nsIXPCTestParentOne;
60
iParentTwo = Components.interfaces.nsIXPCTestParentTwo;
63
CONTRACTID = "@mozilla.org/js/xpc/test/Child2;1";
64
cChild = Components.classes[CONTRACTID].createInstance();
65
CONTRACTID = "@mozilla.org/js/xpc/test/ParentOne;1";
66
cParentOne = Components.classes[CONTRACTID].createInstance();
67
CONTRACTID = "@mozilla.org/js/xpc/test/ParentTwo;1";
68
cParentTwo = Components.classes[CONTRACTID].createInstance();
70
c_c2 = cChild.QueryInterface(iChild);
71
c_p1 = cChild.QueryInterface(iParentOne);
72
c_p2 = cChild.QueryInterface(iParentTwo);
74
parentOne = cParentOne.QueryInterface(iParentOne);
75
parentTwo = cParentTwo.QueryInterface(iParentTwo);
80
"Setting up the test",
82
"FAILED: " + e.message +" "+ e.location +". ");
86
function AddTestData() {
87
Check( cChild, "@mozilla.org/js/xpc/test/Child2;1", c_c2);
88
Check( parentOne, "@mozilla.org/js/xpc/test/Child2;1", c_p1);
89
Check( parentTwo, "@mozilla.org/js/xpc/test/Child2;1", c_p2);
92
function Check( parent, parentName, child) {
93
// child should have all the properties and methods of parentOne
96
for ( p in parent ) parentProps[p] = true;
97
for ( p in child ) if ( parentProps[p] ) parentProps[p] = false;
99
for ( p in parentProps ) {
101
"child has property " + p,
103
(parentProps[p] ? false : true )
106
if ( p.match(/Method/) ) {
109
parentName +" method",
112
} else if (p.match(/Attribute/)) {
115
parentName+" attribute",
121
for ( p in parentProps ) {
122
if ( parentProps[p] == true )
127
"child has all parent properties?",
133
"child has property " + p,
135
(child[p] ? true : false )
138
if ( p.match(/Method/) ) {
141
parentName +" method",
144
} else if (p.match(/Attribute/)) {
147
parentName +" attribute",