summaryrefslogtreecommitdiffstats
path: root/content/test
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-17 23:16:36 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-17 23:16:36 +0000
commit6289ffbc2945eda8893b5fcf899e87539214ddc9 (patch)
tree91885e4bf204ae4983cef9dfbbbff666abdf0d6b /content/test
parented3fb97591a93db1cdc6c7bbb07604d01948d50e (diff)
downloadchromium_src-6289ffbc2945eda8893b5fcf899e87539214ddc9.zip
chromium_src-6289ffbc2945eda8893b5fcf899e87539214ddc9.tar.gz
chromium_src-6289ffbc2945eda8893b5fcf899e87539214ddc9.tar.bz2
Move in-process-webkit unit tests to content unit tests target
BUG=90443 TEST=nothing breaks Review URL: http://codereview.chromium.org/8208008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105955 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/test')
-rw-r--r--content/test/run_all_unittests.cc3
-rw-r--r--content/test/test_browser_context.cc4
-rw-r--r--content/test/test_browser_context.h4
-rw-r--r--content/test/unittest_test_suite.cc37
-rw-r--r--content/test/unittest_test_suite.h38
5 files changed, 84 insertions, 2 deletions
diff --git a/content/test/run_all_unittests.cc b/content/test/run_all_unittests.cc
index 331f0ce..2a66953 100644
--- a/content/test/run_all_unittests.cc
+++ b/content/test/run_all_unittests.cc
@@ -3,7 +3,8 @@
// found in the LICENSE file.
#include "content/test/content_test_suite.h"
+#include "content/test/unittest_test_suite.h"
int main(int argc, char** argv) {
- return ContentTestSuite(argc, argv).Run();
+ return UnitTestTestSuite(new ContentTestSuite(argc, argv)).Run();
}
diff --git a/content/test/test_browser_context.cc b/content/test/test_browser_context.cc
index 46ec0ec..7a7af59 100644
--- a/content/test/test_browser_context.cc
+++ b/content/test/test_browser_context.cc
@@ -7,15 +7,17 @@
#include "base/file_path.h"
#include "content/browser/in_process_webkit/webkit_context.h"
#include "content/browser/mock_resource_context.h"
+#include "testing/gtest/include/gtest/gtest.h"
TestBrowserContext::TestBrowserContext() {
+ EXPECT_TRUE(browser_context_dir_.CreateUniqueTempDir());
}
TestBrowserContext::~TestBrowserContext() {
}
FilePath TestBrowserContext::GetPath() {
- return FilePath();
+ return browser_context_dir_.path();
}
bool TestBrowserContext::IsOffTheRecord() {
diff --git a/content/test/test_browser_context.h b/content/test/test_browser_context.h
index 7d26d16..b35a678 100644
--- a/content/test/test_browser_context.h
+++ b/content/test/test_browser_context.h
@@ -7,7 +7,9 @@
#pragma once
#include "base/compiler_specific.h"
+#include "base/file_path.h"
#include "base/memory/ref_counted.h"
+#include "base/scoped_temp_dir.h"
#include "content/browser/browser_context.h"
class WebKitContext;
@@ -42,6 +44,8 @@ class TestBrowserContext : public content::BrowserContext {
// WebKitContext, lazily initialized by GetWebKitContext().
scoped_refptr<WebKitContext> webkit_context_;
+ ScopedTempDir browser_context_dir_;
+
DISALLOW_COPY_AND_ASSIGN(TestBrowserContext);
};
diff --git a/content/test/unittest_test_suite.cc b/content/test/unittest_test_suite.cc
new file mode 100644
index 0000000..932229a
--- /dev/null
+++ b/content/test/unittest_test_suite.cc
@@ -0,0 +1,37 @@
+// 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.
+
+#include "content/test/unittest_test_suite.h"
+
+#include "base/logging.h"
+#include "base/test/test_suite.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebKitPlatformSupport.h"
+
+// A stubbed out WebKit platform support impl.
+class UnitTestTestSuite::UnitTestWebKitPlatformSupport
+ : public WebKit::WebKitPlatformSupport {
+ public:
+ UnitTestWebKitPlatformSupport() {}
+ virtual ~UnitTestWebKitPlatformSupport() {}
+ virtual void cryptographicallyRandomValues(unsigned char* buffer,
+ size_t length) OVERRIDE {
+ memset(buffer, 0, length);
+ }
+};
+
+UnitTestTestSuite::UnitTestTestSuite(base::TestSuite* test_suite)
+ : test_suite_(test_suite) {
+ DCHECK(test_suite);
+ webkit_platform_support_.reset(new UnitTestWebKitPlatformSupport);
+ WebKit::initialize(webkit_platform_support_.get());
+}
+
+UnitTestTestSuite::~UnitTestTestSuite() {
+ WebKit::shutdown();
+}
+
+int UnitTestTestSuite::Run() {
+ return test_suite_->Run();
+}
diff --git a/content/test/unittest_test_suite.h b/content/test/unittest_test_suite.h
new file mode 100644
index 0000000..64c4ea7
--- /dev/null
+++ b/content/test/unittest_test_suite.h
@@ -0,0 +1,38 @@
+// 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.
+
+#ifndef CONTENT_TEST_UNITTEST_TEST_SUITE_H_
+#define CONTENT_TEST_UNITTEST_TEST_SUITE_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+
+namespace base {
+class TestSuite;
+}
+
+// A special test suite that also initializes WebKit once for all unittests.
+// This is useful for two reasons:
+// 1. It allows the use of some primitive WebKit data types like WebString.
+// 2. Individual unittests should not be initting WebKit on their own, initting
+// it here ensures attempts to do so within an individual test will fail.
+class UnitTestTestSuite {
+ public:
+ // Takes ownership of |test_suite|.
+ explicit UnitTestTestSuite(base::TestSuite* test_suite);
+ ~UnitTestTestSuite();
+
+ int Run();
+
+ private:
+ scoped_ptr<base::TestSuite> test_suite_;
+
+ class UnitTestWebKitPlatformSupport;
+ scoped_ptr<UnitTestWebKitPlatformSupport> webkit_platform_support_;
+
+ DISALLOW_COPY_AND_ASSIGN(UnitTestTestSuite);
+};
+
+#endif // CONTENT_TEST_UNITTEST_TEST_SUITE_H_