Bug 1059572 - Part 0.5: Fixes for pre-existing problems in TestTimers. r=nfroyd
authorByron Campen [:bwc] <docfaraday@gmail.com>
Wed, 29 Jul 2015 11:43:40 -0500
changeset 281621 88854d602d98f67d4d7e541d41d9647373408d1f
parent 281620 d6ae2155496b0082ba76cf3c9cf531bd539d430d
child 281622 7793255f366e01dd38aac596d094c853bc6d94df
push id3894
push usermconley@mozilla.com
push dateThu, 30 Jul 2015 00:27:47 +0000
reviewersnfroyd
bugs1059572
milestone42.0a1
Bug 1059572 - Part 0.5: Fixes for pre-existing problems in TestTimers. r=nfroyd
xpcom/tests/TestTimers.cpp
--- a/xpcom/tests/TestTimers.cpp
+++ b/xpcom/tests/TestTimers.cpp
@@ -55,17 +55,17 @@ private:
   nsCOMPtr<nsIThread> mThread;
 };
 
 class AutoCreateAndDestroyReentrantMonitor
 {
 public:
   AutoCreateAndDestroyReentrantMonitor() {
     mReentrantMonitor = new ReentrantMonitor("TestTimers::AutoMon");
-    NS_ASSERTION(mReentrantMonitor, "Out of memory!");
+    MOZ_ASSERT(mReentrantMonitor, "Out of memory!");
   }
 
   ~AutoCreateAndDestroyReentrantMonitor() {
     delete mReentrantMonitor;
   }
 
   operator ReentrantMonitor* () {
     return mReentrantMonitor;
@@ -79,22 +79,22 @@ class TimerCallback final : public nsITi
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
 
   TimerCallback(nsIThread** aThreadPtr, ReentrantMonitor* aReentrantMonitor)
   : mThreadPtr(aThreadPtr), mReentrantMonitor(aReentrantMonitor) { }
 
   NS_IMETHOD Notify(nsITimer* aTimer) override {
-    NS_ASSERTION(mThreadPtr, "Callback was not supposed to be called!");
+    MOZ_ASSERT(mThreadPtr, "Callback was not supposed to be called!");
     nsCOMPtr<nsIThread> current(do_GetCurrentThread());
 
     ReentrantMonitorAutoEnter mon(*mReentrantMonitor);
 
-    NS_ASSERTION(!*mThreadPtr, "Timer called back more than once!");
+    MOZ_ASSERT(!*mThreadPtr, "Timer called back more than once!");
     *mThreadPtr = current;
 
     mon.Notify();
 
     return NS_OK;
   }
 private:
   ~TimerCallback() {}
@@ -124,18 +124,17 @@ TestTargetedTimers()
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsIThread* notifiedThread = nullptr;
 
   nsCOMPtr<nsITimerCallback> callback =
     new TimerCallback(&notifiedThread, newMon);
   NS_ENSURE_TRUE(callback, NS_ERROR_OUT_OF_MEMORY);
 
-  rv = timer->InitWithCallback(callback, PR_MillisecondsToInterval(2000),
-                               nsITimer::TYPE_ONE_SHOT);
+  rv = timer->InitWithCallback(callback, 2000, nsITimer::TYPE_ONE_SHOT);
   NS_ENSURE_SUCCESS(rv, rv);
 
   ReentrantMonitorAutoEnter mon(*newMon);
   while (!notifiedThread) {
     mon.Wait();
   }
   NS_ENSURE_TRUE(notifiedThread == testThread, NS_ERROR_FAILURE);
 
@@ -157,18 +156,17 @@ TestTimerWithStoppedTarget()
   rv = timer->SetTarget(target);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // If this is called, we'll assert
   nsCOMPtr<nsITimerCallback> callback =
     new TimerCallback(nullptr, nullptr);
   NS_ENSURE_TRUE(callback, NS_ERROR_OUT_OF_MEMORY);
 
-  rv = timer->InitWithCallback(callback, PR_MillisecondsToInterval(100),
-                               nsITimer::TYPE_ONE_SHOT);
+  rv = timer->InitWithCallback(callback, 100, nsITimer::TYPE_ONE_SHOT);
   NS_ENSURE_SUCCESS(rv, rv);
 
   testThread->Shutdown();
 
   PR_Sleep(400);
 
   return NS_OK;
 }