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

Unified Diff: chrome/test/browser/browser_test_launcher_in_proc.cc

Issue 197045: Implement a way to run each interactive UI test isolated (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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/chrome.gyp ('k') | chrome/test/browser/browser_test_launcher_out_of_proc.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/browser/browser_test_launcher_in_proc.cc
===================================================================
--- chrome/test/browser/browser_test_launcher_in_proc.cc (revision 25792)
+++ chrome/test/browser/browser_test_launcher_in_proc.cc (working copy)
@@ -1,124 +0,0 @@
-// Copyright (c) 2009 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 <string>
-
-#include "base/at_exit.h"
-#include "base/command_line.h"
-#include "base/file_path.h"
-#include "base/file_util.h"
-#include "base/logging.h"
-#include "base/native_library.h"
-#include "base/path_service.h"
-#include "base/process_util.h"
-#include "base/string_util.h"
-
-#include "chrome/test/browser/browser_test_runner.h"
-
-// This version of the browser test launcher loads a dynamic library containing
-// the tests and executes the them in that library. When the test has been run
-// the library is unloaded, to ensure atexit handlers are run and static
-// initializers will be run again for the next test.
-
-namespace {
-
-const wchar_t* const kBrowserTesLibBaseName = L"browser_tests";
-const wchar_t* const kGTestListTestsFlag = L"gtest_list_tests";
-
-class InProcBrowserTestRunner : public browser_tests::BrowserTestRunner {
- public:
- InProcBrowserTestRunner() : dynamic_lib_(NULL), run_test_proc_(NULL) {
- }
-
- ~InProcBrowserTestRunner() {
- if (!dynamic_lib_)
- return;
- base::UnloadNativeLibrary(dynamic_lib_);
- LOG(INFO) << "Unloaded " <<
- base::GetNativeLibraryName(kBrowserTesLibBaseName);
- }
-
- bool Init() {
- FilePath lib_path;
- CHECK(PathService::Get(base::FILE_EXE, &lib_path));
- lib_path = lib_path.DirName().Append(
- base::GetNativeLibraryName(kBrowserTesLibBaseName));
-
- LOG(INFO) << "Loading '" << lib_path.value() << "'";
-
- dynamic_lib_ = base::LoadNativeLibrary(lib_path);
- if (!dynamic_lib_) {
- LOG(ERROR) << "Failed to load " << lib_path.value();
- return false;
- }
-
- run_test_proc_ = reinterpret_cast<RunTestProc>(
- base::GetFunctionPointerFromNativeLibrary(dynamic_lib_, "RunTests"));
- if (!run_test_proc_) {
- LOG(ERROR) <<
- "Failed to find RunTest function in " << lib_path.value();
- return false;
- }
-
- return true;
- }
-
- // Returns true if the test succeeded, false if it failed.
- bool RunTest(const std::string& test_name) {
- std::string filter_flag = StringPrintf("--gtest_filter=%s",
- test_name.c_str());
- char* argv[3];
- argv[0] = const_cast<char*>("");
- argv[1] = const_cast<char*>(filter_flag.c_str());
- // Always enable disabled tests. This method is not called with disabled
- // tests unless this flag was specified to the browser test executable.
- argv[2] = "--gtest_also_run_disabled_tests";
- return RunAsIs(3, argv) == 0;
- }
-
- // Calls-in to GTest with the arguments we were started with.
- int RunAsIs(int argc, char** argv) {
- return (run_test_proc_)(argc, argv);
- }
-
- private:
- typedef int (CDECL *RunTestProc)(int, char**);
-
- base::NativeLibrary dynamic_lib_;
- RunTestProc run_test_proc_;
-
- DISALLOW_COPY_AND_ASSIGN(InProcBrowserTestRunner);
-};
-
-class InProcBrowserTestRunnerFactory
- : public browser_tests::BrowserTestRunnerFactory {
- public:
- InProcBrowserTestRunnerFactory() { }
-
- virtual browser_tests::BrowserTestRunner* CreateBrowserTestRunner() const {
- return new InProcBrowserTestRunner();
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(InProcBrowserTestRunnerFactory);
-};
-
-} // namespace
-
-int main(int argc, char** argv) {
- base::AtExitManager at_exit_manager;
-
- CommandLine::Init(argc, argv);
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
-
- if (command_line->HasSwitch(kGTestListTestsFlag)) {
- InProcBrowserTestRunner test_runner;
- if (!test_runner.Init())
- return 1;
- return test_runner.RunAsIs(argc, argv);
- }
-
- InProcBrowserTestRunnerFactory test_runner_factory;
- return browser_tests::RunTests(test_runner_factory) ? 0 : 1;
-}
« no previous file with comments | « chrome/chrome.gyp ('k') | chrome/test/browser/browser_test_launcher_out_of_proc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698