Bug 1276669 - Part 5: Don't try to test NS_RegisterStaticAtoms. r=erahm, a=ritu
authorNathan Froyd <froydnj@mozilla.com>
Thu, 26 Jan 2017 15:43:39 -0500
changeset 375822 c1b5e94191ec94a36a2c01a161933ce7ee43d7e8
parent 375821 a5abb9c78e53ff6083c4e81cad93416b2492c8e9
child 375823 d5ccf239c1423f30e1a9ea1491a8ee7201ef199b
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm, ritu
bugs1276669
milestone53.0a2
Bug 1276669 - Part 5: Don't try to test NS_RegisterStaticAtoms. r=erahm, a=ritu There are several XPCOM tests that purport to call NS_RegisterStaticAtoms. The tests located in the xpcom/tests/ directory are unused, so we might as well just remove them. The gtests do get run, but there's going to be no way to test NS_RegisterStaticAtoms once sealing the atom table actually means forbidding new additions. So we might as well remove the gtest too.
xpcom/tests/MoreTestingAtomList.h
xpcom/tests/MoreTestingAtoms.cpp
xpcom/tests/MoreTestingAtoms.h
xpcom/tests/TestStaticAtoms.cpp
xpcom/tests/TestingAtoms.cpp
xpcom/tests/TestingAtoms.h
xpcom/tests/gtest/TestAtoms.cpp
xpcom/tests/moz.build
deleted file mode 100644
--- a/xpcom/tests/MoreTestingAtomList.h
+++ /dev/null
@@ -1,6 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-MORE_TESTING_ATOM(qux, "qux")
-MORE_TESTING_ATOM(quux, "quux")
deleted file mode 100644
--- a/xpcom/tests/MoreTestingAtoms.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "MoreTestingAtoms.h"
-#include "nsStaticAtom.h"
-#include "nsMemory.h"
-
-// define storage for all atoms
-#define MORE_TESTING_ATOM(_name, _value) nsIAtom* MoreTestingAtoms::_name;
-#include "MoreTestingAtomList.h"
-#undef MORE_TESTING_ATOM
-
-#define MORE_TESTING_ATOM(name_, value_) NS_STATIC_ATOM_BUFFER(name_##_buffer, value_)
-#include "MoreTestingAtomList.h"
-#undef MORE_TESTING_ATOM
-
-static const nsStaticAtom MoreTestingAtoms_info[] = {
-
-#define MORE_TESTING_ATOM(name_, value_) NS_STATIC_ATOM(name_##_buffer, &MoreTestingAtoms::name_),
-#include "MoreTestingAtomList.h"
-#undef MORE_TESTING_ATOM
-};
-
-void MoreTestingAtoms::AddRefAtoms()
-{
-  NS_RegisterStaticAtoms(MoreTestingAtoms_info);
-}
deleted file mode 100644
--- a/xpcom/tests/MoreTestingAtoms.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
- 
-#ifndef MoreTestingAtoms_h_
-#define MoreTestingAtoms_h_
-
-#include "nsIAtom.h"
-
-class MoreTestingAtoms {
-  public:
-    static void AddRefAtoms();
-#define MORE_TESTING_ATOM(_name, _value) static nsIAtom* _name;
-#include "MoreTestingAtomList.h"
-#undef MORE_TESTING_ATOM
-};
-
-#endif /* MoreTestingAtoms_h_ */
deleted file mode 100644
--- a/xpcom/tests/TestStaticAtoms.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "TestHarness.h"
-#include "TestingAtoms.cpp"
-#include "MoreTestingAtoms.cpp"
-
-int main(int argc, char** argv)
-{
-  ScopedXPCOM xpcom("TestStaticAtoms");
-  if (xpcom.failed()) {
-    return 1;
-  }
-
-  TestingAtoms::AddRefAtoms();
-
-  NS_SealStaticAtomTable();
-
-  nsCOMPtr<nsIAtom> atom = NS_Atomize("foo");
-  if (!atom) {
-    fail("Didn't get an atom for foo.");
-    return 1;
-  }
-  if (atom->IsStaticAtom()) {
-    passed("foo is a static atom");
-  } else {
-    fail("foo is not a static atom.");
-    return 1;
-  }
-  if (atom == TestingAtoms::foo) {
-    passed("foo is the right pointer");
-  } else {
-    fail("foo was not the right pointer");
-    return 1;
-  }
-  nsIAtom* staticAtom = NS_GetStaticAtom(NS_LITERAL_STRING("foo"));
-  if (!staticAtom) {
-    fail("Did not get a static atom for foo");
-    return 1;
-  }
-
-  if (atom == staticAtom) {
-    passed("NS_Atomize and NS_GetStaticAtom returned the same atom.");
-  } else {
-    fail("NS_Atomize and NS_GetStaticAtom returned different atoms.");
-    return 1;
-  }
-
-  MoreTestingAtoms::AddRefAtoms();
-  
-  atom = NS_Atomize("qux");
-  if (!atom) {
-    fail("Didn't get an atom for qux.");
-    return 1;
-  }
-  if (atom->IsStaticAtom()) {
-    passed("qux is a static atom");
-  } else {
-    fail("qux is not a static atom.");
-    return 1;
-  }
-  if (atom == MoreTestingAtoms::qux) {
-    passed("qux is the right pointer");
-  } else {
-    fail("qux was not the right pointer");
-    return 1;
-  }
-  staticAtom = NS_GetStaticAtom(NS_LITERAL_STRING("qux"));
-  if (staticAtom) {
-    fail("Got an atom for qux. The static atom table was not sealed properly.");
-    return 1;
-  }
-  return 0;
-}
deleted file mode 100644
--- a/xpcom/tests/TestingAtoms.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "TestingAtoms.h"
-#include "nsStaticAtom.h"
-#include "nsMemory.h"
-
-// define storage for all atoms
-#define TESTING_ATOM(_name, _value) nsIAtom* TestingAtoms::_name;
-#include "TestingAtomList.h"
-#undef TESTING_ATOM
-
-#define TESTING_ATOM(name_, value_) NS_STATIC_ATOM_BUFFER(name_##_buffer, value_)
-#include "TestingAtomList.h"
-#undef TESTING_ATOM
-
-static const nsStaticAtom TestingAtoms_info[] = {
-#define TESTING_ATOM(name_, value_) NS_STATIC_ATOM(name_##_buffer, &TestingAtoms::name_),
-#include "TestingAtomList.h"
-#undef TESTING_ATOM
-};
-
-void TestingAtoms::AddRefAtoms()
-{
-  NS_RegisterStaticAtoms(TestingAtoms_info);
-}
deleted file mode 100644
--- a/xpcom/tests/TestingAtoms.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
- 
-#ifndef TestingAtoms_h_
-#define TestingAtoms_h_
-
-#include "nsIAtom.h"
-
-class TestingAtoms {
-  public:
-    static void AddRefAtoms();
-#define TESTING_ATOM(_name, _value) static nsIAtom* _name;
-#include "TestingAtomList.h"
-#undef TESTING_ATOM
-};
-
-#endif /* TestingAtoms_h_ */
--- a/xpcom/tests/gtest/TestAtoms.cpp
+++ b/xpcom/tests/gtest/TestAtoms.cpp
@@ -117,28 +117,16 @@ TEST(Atoms, Invalid)
   }
 #endif
 }
 
 #define FIRST_ATOM_STR "first static atom. Hello!"
 #define SECOND_ATOM_STR "second static atom. @World!"
 #define THIRD_ATOM_STR "third static atom?!"
 
-static nsIAtom* sAtom1 = 0;
-static nsIAtom* sAtom2 = 0;
-static nsIAtom* sAtom3 = 0;
-NS_STATIC_ATOM_BUFFER(sAtom1_buffer, FIRST_ATOM_STR)
-NS_STATIC_ATOM_BUFFER(sAtom2_buffer, SECOND_ATOM_STR)
-NS_STATIC_ATOM_BUFFER(sAtom3_buffer, THIRD_ATOM_STR)
-static const nsStaticAtom sAtoms_info[] = {
-  NS_STATIC_ATOM(sAtom1_buffer, &sAtom1),
-  NS_STATIC_ATOM(sAtom2_buffer, &sAtom2),
-  NS_STATIC_ATOM(sAtom3_buffer, &sAtom3),
-};
-
 bool
 isStaticAtom(nsIAtom* atom)
 {
   // Don't use logic && in order to ensure that all addrefs/releases are always
   // run, even if one of the tests fail. This allows us to run this code on a
   // non-static atom without affecting its refcount.
   bool rv = (atom->AddRef() == 2);
   rv &= (atom->AddRef() == 2);
@@ -155,25 +143,11 @@ TEST(Atoms, Table)
   nsrefcnt count = NS_GetNumberOfAtoms();
 
   nsCOMPtr<nsIAtom> thirdDynamic = NS_Atomize(THIRD_ATOM_STR);
 
   EXPECT_FALSE(isStaticAtom(thirdDynamic));
 
   EXPECT_TRUE(thirdDynamic);
   EXPECT_EQ(NS_GetNumberOfAtoms(), count + 1);
-
-  NS_RegisterStaticAtoms(sAtoms_info);
-
-  EXPECT_TRUE(sAtom1);
-  EXPECT_TRUE(sAtom1->Equals(NS_LITERAL_STRING(FIRST_ATOM_STR)));
-  EXPECT_TRUE(isStaticAtom(sAtom1));
-  EXPECT_TRUE(sAtom2);
-  EXPECT_TRUE(sAtom2->Equals(NS_LITERAL_STRING(SECOND_ATOM_STR)));
-  EXPECT_TRUE(isStaticAtom(sAtom2));
-  EXPECT_TRUE(sAtom3);
-  EXPECT_TRUE(sAtom3->Equals(NS_LITERAL_STRING(THIRD_ATOM_STR)));
-  EXPECT_TRUE(isStaticAtom(sAtom3));
-  EXPECT_EQ(NS_GetNumberOfAtoms(), count + 3);
-  EXPECT_EQ(thirdDynamic, sAtom3);
 }
 
 }
--- a/xpcom/tests/moz.build
+++ b/xpcom/tests/moz.build
@@ -22,21 +22,16 @@ SimplePrograms([
     'TestQuickReturn',
     'TestUnicodeArguments',
 ])
 
 USE_LIBS += ['mfbt']
 
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
-# FIXME: bug 577500 TestStaticAtoms fails when run in dist/bin
-#CPP_UNIT_TESTS += [
-#    'TestStaticAtoms',
-#]
-
 if CONFIG['COMPILE_ENVIRONMENT']:
     TEST_HARNESS_FILES.xpcshell.xpcom.tests.unit += [
         '!/dist/bin/components/xpcomtest.xpt',
     ]
 
 XPIDL_MODULE = 'xpcomtest'
 XPIDL_SOURCES += [
     'NotXPCOMTest.idl',