2012-04-03 03:34:16 +02:00
|
|
|
// Copyright (c) 2011 The Chromium Embedded Framework 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 "tests/unittests/test_suite.h"
|
2014-07-15 00:18:51 +02:00
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "base/command_line.h"
|
|
|
|
#include "base/logging.h"
|
|
|
|
#include "base/test/test_suite.h"
|
|
|
|
|
|
|
|
#if defined(OS_MACOSX)
|
2012-11-05 21:18:20 +01:00
|
|
|
#include "base/debug/stack_trace.h"
|
2013-03-19 23:59:33 +01:00
|
|
|
#include "base/files/file_path.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "base/i18n/icu_util.h"
|
|
|
|
#include "base/path_service.h"
|
|
|
|
#include "base/test/test_timeouts.h"
|
|
|
|
#endif
|
|
|
|
|
2015-01-31 01:55:56 +01:00
|
|
|
#include "tests/cefclient/common/client_switches.h"
|
2014-07-15 00:18:51 +02:00
|
|
|
|
2015-01-09 18:22:10 +01:00
|
|
|
base::CommandLine* CefTestSuite::commandline_ = NULL;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
CefTestSuite::CefTestSuite(int argc, char** argv)
|
|
|
|
: TestSuite(argc, argv) {
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
void CefTestSuite::InitCommandLine(int argc, const char* const* argv) {
|
|
|
|
if (commandline_) {
|
|
|
|
// If this is intentional, Reset() must be called first. If we are using
|
|
|
|
// the shared build mode, we have to share a single object across multiple
|
|
|
|
// shared libraries.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-09 18:22:10 +01:00
|
|
|
commandline_ = new base::CommandLine(base::CommandLine::NO_PROGRAM);
|
2012-04-03 03:34:16 +02:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
commandline_->ParseFromString(::GetCommandLineW());
|
|
|
|
#elif defined(OS_POSIX)
|
|
|
|
commandline_->InitFromArgv(argc, argv);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
void CefTestSuite::GetSettings(CefSettings& settings) {
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
settings.multi_threaded_message_loop =
|
2015-01-23 20:09:34 +01:00
|
|
|
commandline_->HasSwitch(client::switches::kMultiThreadedMessageLoop);
|
2012-04-03 03:34:16 +02:00
|
|
|
#endif
|
|
|
|
|
2016-05-04 20:00:03 +02:00
|
|
|
if (!settings.multi_threaded_message_loop) {
|
|
|
|
settings.external_message_pump =
|
|
|
|
commandline_->HasSwitch(client::switches::kExternalMessagePump);
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
CefString(&settings.cache_path) =
|
2015-01-23 20:09:34 +01:00
|
|
|
commandline_->GetSwitchValueASCII(client::switches::kCachePath);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// Always expose the V8 gc() function to give tests finer-grained control over
|
|
|
|
// memory management.
|
|
|
|
std::string javascript_flags = "--expose-gc";
|
2012-06-12 17:53:39 +02:00
|
|
|
// Value of kJavascriptFlags switch.
|
2012-04-03 03:34:16 +02:00
|
|
|
std::string other_javascript_flags =
|
2012-06-12 17:53:39 +02:00
|
|
|
commandline_->GetSwitchValueASCII("js-flags");
|
2012-04-03 03:34:16 +02:00
|
|
|
if (!other_javascript_flags.empty())
|
|
|
|
javascript_flags += " " + other_javascript_flags;
|
|
|
|
CefString(&settings.javascript_flags) = javascript_flags;
|
2012-11-02 19:16:28 +01:00
|
|
|
|
|
|
|
// Necessary for V8Test.OnUncaughtException tests.
|
|
|
|
settings.uncaught_exception_stack_size = 10;
|
2014-07-01 00:30:29 +02:00
|
|
|
|
|
|
|
// Necessary for the OSRTest tests.
|
|
|
|
settings.windowless_rendering_enabled = true;
|
2015-02-18 18:28:56 +01:00
|
|
|
|
|
|
|
// For Accept-Language test
|
|
|
|
CefString(&settings.accept_language_list) = CEF_SETTINGS_ACCEPT_LANGUAGE;
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
bool CefTestSuite::GetCachePath(std::string& path) {
|
|
|
|
DCHECK(commandline_);
|
|
|
|
|
2015-01-23 20:09:34 +01:00
|
|
|
if (commandline_->HasSwitch(client::switches::kCachePath)) {
|
2012-04-03 03:34:16 +02:00
|
|
|
// Set the cache_path value.
|
2015-01-23 20:09:34 +01:00
|
|
|
path = commandline_->GetSwitchValueASCII(client::switches::kCachePath);
|
2012-04-03 03:34:16 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
void CefTestSuite::Initialize() {
|
|
|
|
// The below code is copied from base/test/test_suite.cc to avoid calling
|
|
|
|
// RegisterMockCrApp() on Mac.
|
|
|
|
|
2013-02-27 19:34:27 +01:00
|
|
|
base::FilePath exe;
|
2012-04-03 03:34:16 +02:00
|
|
|
PathService::Get(base::FILE_EXE, &exe);
|
2013-07-19 01:25:28 +02:00
|
|
|
|
|
|
|
// Initialize logging.
|
|
|
|
logging::LoggingSettings log_settings;
|
|
|
|
log_settings.log_file =
|
|
|
|
exe.ReplaceExtension(FILE_PATH_LITERAL("log")).value().c_str();
|
|
|
|
log_settings.logging_dest = logging::LOG_TO_ALL;
|
|
|
|
log_settings.lock_log = logging::LOCK_LOG_FILE;
|
|
|
|
log_settings.delete_old = logging::DELETE_OLD_LOG_FILE;
|
|
|
|
logging::InitLogging(log_settings);
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
// We want process and thread IDs because we may have multiple processes.
|
|
|
|
// Note: temporarily enabled timestamps in an effort to catch bug 6361.
|
|
|
|
logging::SetLogItems(true, true, true, true);
|
|
|
|
|
2012-11-05 21:18:20 +01:00
|
|
|
CHECK(base::debug::EnableInProcessStackDumping());
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// In some cases, we do not want to see standard error dialogs.
|
|
|
|
if (!base::debug::BeingDebugged() &&
|
2015-01-09 18:22:10 +01:00
|
|
|
!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
|
|
|
"show-error-dialogs")) {
|
2012-04-03 03:34:16 +02:00
|
|
|
SuppressErrorDialogs();
|
|
|
|
base::debug::SetSuppressDebugUI(true);
|
|
|
|
logging::SetLogAssertHandler(UnitTestAssertHandler);
|
|
|
|
}
|
|
|
|
|
2013-09-04 00:32:29 +02:00
|
|
|
base::i18n::InitializeICU();
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
CatchMaybeTests();
|
|
|
|
ResetCommandLine();
|
|
|
|
|
|
|
|
TestTimeouts::Initialize();
|
|
|
|
}
|
|
|
|
#endif // defined(OS_MACOSX)
|