Upstream version 5.34.97.0
[platform/framework/web/crosswalk.git] / src / xwalk / test / base / in_process_browser_test.cc
index 9cfb8ab..abb6d4c 100644 (file)
@@ -52,12 +52,20 @@ base::LazyInstance<XWalkContentRendererClient>::Leaky
 
 }  // namespace
 
+RuntimeRegistry::RuntimeRegistry() {
+}
+
 RuntimeRegistry::~RuntimeRegistry() {
 }
 
 void RuntimeRegistry::CloseAll() {
+  if (runtimes_.empty())
+    return;
+
   RuntimeList cached(runtimes_);
   std::for_each(cached.begin(), cached.end(), std::mem_fun(&Runtime::Close));
+  // Wait until all windows are closed.
+  content::RunAllPendingInMessageLoop();
   DCHECK(runtimes_.empty()) << runtimes_.size();
 }
 
@@ -147,10 +155,7 @@ void InProcessBrowserTest::RunTestOnMainThreadLoop() {
 
   // Invoke cleanup and quit even if there are failures. This is similar to
   // gtest in that it invokes TearDown even if Setup fails.
-  CleanUpOnMainThread();
-  // Sometimes tests leave Quit tasks in the MessageLoop (for shame), so let's
-  // run all pending messages here to avoid preempting the QuitBrowsers tasks.
-  content::RunAllPendingInMessageLoop();
+  ProperMainThreadCleanup();
 
   runtime_registry_->CloseAll();
 }