|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #include "TestHarness.h" |
|
6 #include "TestingAtoms.cpp" |
|
7 #include "MoreTestingAtoms.cpp" |
|
8 |
|
9 int main(int argc, char** argv) |
|
10 { |
|
11 ScopedXPCOM xpcom("TestStaticAtoms"); |
|
12 if (xpcom.failed()) { |
|
13 return 1; |
|
14 } |
|
15 |
|
16 TestingAtoms::AddRefAtoms(); |
|
17 |
|
18 NS_SealStaticAtomTable(); |
|
19 |
|
20 nsCOMPtr<nsIAtom> atom = do_GetAtom("foo"); |
|
21 if (!atom) { |
|
22 fail("Didn't get an atom for foo."); |
|
23 return 1; |
|
24 } |
|
25 if (atom->IsStaticAtom()) { |
|
26 passed("foo is a static atom"); |
|
27 } else { |
|
28 fail("foo is not a static atom."); |
|
29 return 1; |
|
30 } |
|
31 if (atom == TestingAtoms::foo) { |
|
32 passed("foo is the right pointer"); |
|
33 } else { |
|
34 fail("foo was not the right pointer"); |
|
35 return 1; |
|
36 } |
|
37 nsIAtom* staticAtom = NS_GetStaticAtom(NS_LITERAL_STRING("foo")); |
|
38 if (!staticAtom) { |
|
39 fail("Did not get a static atom for foo"); |
|
40 return 1; |
|
41 } |
|
42 |
|
43 if (atom == staticAtom) { |
|
44 passed("do_GetAtom and NS_GetStaticAtom returned the same atom."); |
|
45 } else { |
|
46 fail("do_GetAtom and NS_GetStaticAtom returned different atoms."); |
|
47 return 1; |
|
48 } |
|
49 |
|
50 MoreTestingAtoms::AddRefAtoms(); |
|
51 |
|
52 atom = do_GetAtom("qux"); |
|
53 if (!atom) { |
|
54 fail("Didn't get an atom for qux."); |
|
55 return 1; |
|
56 } |
|
57 if (atom->IsStaticAtom()) { |
|
58 passed("qux is a static atom"); |
|
59 } else { |
|
60 fail("qux is not a static atom."); |
|
61 return 1; |
|
62 } |
|
63 if (atom == MoreTestingAtoms::qux) { |
|
64 passed("qux is the right pointer"); |
|
65 } else { |
|
66 fail("qux was not the right pointer"); |
|
67 return 1; |
|
68 } |
|
69 staticAtom = NS_GetStaticAtom(NS_LITERAL_STRING("qux")); |
|
70 if (staticAtom) { |
|
71 fail("Got an atom for qux. The static atom table was not sealed properly."); |
|
72 return 1; |
|
73 } |
|
74 return 0; |
|
75 } |