summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-03 02:22:02 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-03 02:22:02 +0000
commita70b0a781ee5fb44a82887ed9e76e6a0d80d64e3 (patch)
tree6f44b79e43ea61783b12dd7849ac938f8f834d29
parente7a0a59da27a34bd0677b0f4b7862174f21e3027 (diff)
downloadchromium_src-a70b0a781ee5fb44a82887ed9e76e6a0d80d64e3.zip
chromium_src-a70b0a781ee5fb44a82887ed9e76e6a0d80d64e3.tar.gz
chromium_src-a70b0a781ee5fb44a82887ed9e76e6a0d80d64e3.tar.bz2
Cleanup base & app unit test MockCrApp NSApp initialization.
Provide chrome unit test CrApplication NSApp initialization. Chrome requires a legitimate message loop for its unit tests. Ensure that init occurs before the base class MockCrApp init. BUG=71686 TEST=Run all base/app/chrome unit tests on Mac; try bug repro Review URL: http://codereview.chromium.org/6349058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73581 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--app/test_suite.h10
-rw-r--r--base/mac/mac_util_unittest.mm4
-rw-r--r--base/test/test_suite.cc9
-rw-r--r--chrome/test/unit/chrome_test_suite.cc7
4 files changed, 18 insertions, 12 deletions
diff --git a/app/test_suite.h b/app/test_suite.h
index 519f445..72cc28c 100644
--- a/app/test_suite.h
+++ b/app/test_suite.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -18,7 +18,6 @@
#if defined(OS_MACOSX)
#include "base/mac/mac_util.h"
-#include "base/test/mock_chrome_application_mac.h"
#endif
class AppTestSuite : public base::TestSuite {
@@ -29,14 +28,9 @@ class AppTestSuite : public base::TestSuite {
protected:
virtual void Initialize() {
-#if defined(OS_MACOSX)
- // Some of the app unit tests try to open windows.
- mock_cr_app::RegisterMockCrApp();
-#endif
-
base::mac::ScopedNSAutoreleasePool autorelease_pool;
- TestSuite::Initialize();
+ base::TestSuite::Initialize();
app::RegisterPathProvider();
ui::RegisterPathProvider();
diff --git a/base/mac/mac_util_unittest.mm b/base/mac/mac_util_unittest.mm
index 47ecebf..17fc04f 100644
--- a/base/mac/mac_util_unittest.mm
+++ b/base/mac/mac_util_unittest.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,7 +10,6 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/mac/scoped_cftyperef.h"
-#include "base/test/mock_chrome_application_mac.h"
#include "base/scoped_nsobject.h"
#include "base/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -55,7 +54,6 @@ TEST_F(MacUtilTest, TestLibraryPath) {
TEST_F(MacUtilTest, TestGrabWindowSnapshot) {
// Launch a test window so we can take a snapshot.
- [MockCrApp sharedApplication];
NSRect frame = NSMakeRect(0, 0, 400, 400);
scoped_nsobject<NSWindow> window(
[[NSWindow alloc] initWithContentRect:frame
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
index 5f8a616..447a138a 100644
--- a/base/test/test_suite.cc
+++ b/base/test/test_suite.cc
@@ -24,6 +24,10 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"
+#if defined(OS_MACOSX)
+#include "base/test/mock_chrome_application_mac.h"
+#endif
+
#if defined(TOOLKIT_USES_GTK)
#include <gtk/gtk.h>
#endif
@@ -171,6 +175,11 @@ void TestSuite::SuppressErrorDialogs() {
}
void TestSuite::Initialize() {
+#if defined(OS_MACOSX)
+ // Some of the app unit tests spin runloops.
+ mock_cr_app::RegisterMockCrApp();
+#endif
+
// Initialize logging.
FilePath exe;
PathService::Get(base::FILE_EXE, &exe);
diff --git a/chrome/test/unit/chrome_test_suite.cc b/chrome/test/unit/chrome_test_suite.cc
index 5dfac21..10812d4 100644
--- a/chrome/test/unit/chrome_test_suite.cc
+++ b/chrome/test/unit/chrome_test_suite.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -21,6 +21,7 @@
#if defined(OS_MACOSX)
#include "base/mac/mac_util.h"
+#include "chrome/common/chrome_application_mac.h"
#endif
#if defined(OS_POSIX)
@@ -85,6 +86,10 @@ ChromeTestSuite::~ChromeTestSuite() {
}
void ChromeTestSuite::Initialize() {
+#if defined(OS_MACOSX)
+ chrome_application_mac::RegisterCrApp();
+#endif
+
base::mac::ScopedNSAutoreleasePool autorelease_pool;
base::TestSuite::Initialize();