Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Unified Diff: chrome/test/base/browser_with_content_test.cc

Issue 1393233002: Mac Energy Test Harness/Framework Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Snapshot of scripts for http://crbug.com/391646 Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/base/browser_with_content_test.h ('k') | chrome/test/base/testing_profile.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/browser_with_content_test.cc
diff --git a/chrome/test/base/browser_with_content_test.cc b/chrome/test/base/browser_with_content_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cd1411a7b5656e737a4d67037a16d861556572ab
--- /dev/null
+++ b/chrome/test/base/browser_with_content_test.cc
@@ -0,0 +1,88 @@
+// Copyright 2014 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 "chrome/test/base/browser_with_content_test.h"
+
+#include "base/base_paths.h"
+#include "base/command_line.h"
+#include "base/files/file_path.h"
+#include "base/logging.h"
+#include "base/path_service.h"
+#include "base/run_loop.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/common/chrome_constants.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/test/base/chrome_unit_test_suite.h"
+#include "chrome/test/base/testing_browser_process.h"
+#include "chrome/test/base/testing_profile.h"
+#include "content/public/common/content_switches.h"
+
+#if defined(OS_MACOSX)
+#include "base/mac/scoped_nsautorelease_pool.h"
+#include "chrome/test/base/scoped_bundle_swizzler_mac.h"
+#endif
+
+BrowserWithContentTest::BrowserWithContentTest() {
+#if defined(OS_MACOSX)
+ // TODO(phajdan.jr): Make browser_tests self-contained on Mac, remove this.
+ // Before we run the browser, we have to hack the path to the exe to match
+ // what it would be if Chrome was running, because it is used to fork renderer
+ // processes, on Linux at least (failure to do so will cause a browser_test to
+ // be run instead of a renderer).
+ base::FilePath chrome_path;
+ CHECK(PathService::Get(base::FILE_EXE, &chrome_path));
+ chrome_path = chrome_path.DirName();
+ chrome_path = chrome_path.Append(chrome::kBrowserProcessExecutablePath);
+ CHECK(PathService::Override(base::FILE_EXE, chrome_path));
+#endif // defined(OS_MACOSX)
+
+ base::FilePath src_dir;
+ CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir));
+ base::FilePath test_data_dir = src_dir.AppendASCII("chrome/test/data");
+
+#if 0
+ CreateTestServer(base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
+ embedded_test_server()->ServeFilesFromDirectory(test_data_dir);
+#endif
+
+ ChromeUnitTestSuite::InitializeProviders();
+ ChromeUnitTestSuite::InitializeResourceBundle();
+
+#if defined(OS_MACOSX)
+ bundle_swizzler_.reset(new ScopedBundleSwizzlerMac);
+#endif
+}
+
+BrowserWithContentTest::~BrowserWithContentTest() {}
+
+void BrowserWithContentTest::SetUp() {
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ command_line->AppendSwitchASCII(switches::kTestType, "browser_with_content");
+ SetUpCommandLine(command_line);
+
+ // Create the first Browser here rather than in SetUpOnMainThread() since the
+ // initialization uses banned IO tasks.
+ TestingBrowserProcess::CreateInstance();
+ profile_.reset(new TestingProfile);
+ browser_ = new Browser(
+ Browser::CreateParams(profile_.get(), chrome::GetActiveDesktop()));
+
+ content::BrowserTestBase::SetUp();
+}
+
+void BrowserWithContentTest::SetUpOnMainThread() {}
+
+void BrowserWithContentTest::TearDownOnMainThread() {
+ profile_.reset();
+ /* close browser */
+ TestingBrowserProcess::DeleteInstance();
+}
+
+void BrowserWithContentTest::RunTestOnMainThreadLoop() {
+ base::RunLoop().RunUntilIdle();
+
+ SetUpOnMainThread();
+ RunTestOnMainThread();
+ TearDownOnMainThread();
+}
« no previous file with comments | « chrome/test/base/browser_with_content_test.h ('k') | chrome/test/base/testing_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698