michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "TestHarness.h" michael@0: #include "TestingAtoms.cpp" michael@0: #include "MoreTestingAtoms.cpp" michael@0: michael@0: int main(int argc, char** argv) michael@0: { michael@0: ScopedXPCOM xpcom("TestStaticAtoms"); michael@0: if (xpcom.failed()) { michael@0: return 1; michael@0: } michael@0: michael@0: TestingAtoms::AddRefAtoms(); michael@0: michael@0: NS_SealStaticAtomTable(); michael@0: michael@0: nsCOMPtr atom = do_GetAtom("foo"); michael@0: if (!atom) { michael@0: fail("Didn't get an atom for foo."); michael@0: return 1; michael@0: } michael@0: if (atom->IsStaticAtom()) { michael@0: passed("foo is a static atom"); michael@0: } else { michael@0: fail("foo is not a static atom."); michael@0: return 1; michael@0: } michael@0: if (atom == TestingAtoms::foo) { michael@0: passed("foo is the right pointer"); michael@0: } else { michael@0: fail("foo was not the right pointer"); michael@0: return 1; michael@0: } michael@0: nsIAtom* staticAtom = NS_GetStaticAtom(NS_LITERAL_STRING("foo")); michael@0: if (!staticAtom) { michael@0: fail("Did not get a static atom for foo"); michael@0: return 1; michael@0: } michael@0: michael@0: if (atom == staticAtom) { michael@0: passed("do_GetAtom and NS_GetStaticAtom returned the same atom."); michael@0: } else { michael@0: fail("do_GetAtom and NS_GetStaticAtom returned different atoms."); michael@0: return 1; michael@0: } michael@0: michael@0: MoreTestingAtoms::AddRefAtoms(); michael@0: michael@0: atom = do_GetAtom("qux"); michael@0: if (!atom) { michael@0: fail("Didn't get an atom for qux."); michael@0: return 1; michael@0: } michael@0: if (atom->IsStaticAtom()) { michael@0: passed("qux is a static atom"); michael@0: } else { michael@0: fail("qux is not a static atom."); michael@0: return 1; michael@0: } michael@0: if (atom == MoreTestingAtoms::qux) { michael@0: passed("qux is the right pointer"); michael@0: } else { michael@0: fail("qux was not the right pointer"); michael@0: return 1; michael@0: } michael@0: staticAtom = NS_GetStaticAtom(NS_LITERAL_STRING("qux")); michael@0: if (staticAtom) { michael@0: fail("Got an atom for qux. The static atom table was not sealed properly."); michael@0: return 1; michael@0: } michael@0: return 0; michael@0: }