diff options
author | Ben Murdoch <benm@google.com> | 2013-07-10 11:40:50 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2013-07-10 11:40:50 +0100 |
commit | eb525c5499e34cc9c4b825d6d9e75bb07cc06ace (patch) | |
tree | d908ce4bfe1717d2cd53f41327d8b9ba8304355f /chrome/test | |
parent | 3c54152607de4272b3da0c146b71dcba8a0e5610 (diff) | |
download | chromium_org-eb525c5499e34cc9c4b825d6d9e75bb07cc06ace.tar.gz |
Merge from Chromium at DEPS revision r210036
This commit was generated by merge_to_master.py.
Change-Id: Ib0e33a83ad5dfa541481e83d7acfc6970e68f471
Diffstat (limited to 'chrome/test')
120 files changed, 1513 insertions, 4602 deletions
diff --git a/chrome/test/DEPS b/chrome/test/DEPS index d0c3c0fe00..8c88f2b3bb 100644 --- a/chrome/test/DEPS +++ b/chrome/test/DEPS @@ -20,4 +20,5 @@ include_rules = [ "+sandbox/win/tests", "+webkit/glue", "+webkit/plugins", + "+win8/test", ] diff --git a/chrome/test/automation/automation_json_requests.cc b/chrome/test/automation/automation_json_requests.cc index 1bc71064fa..28d24af7d5 100644 --- a/chrome/test/automation/automation_json_requests.cc +++ b/chrome/test/automation/automation_json_requests.cc @@ -13,7 +13,7 @@ #include "base/memory/scoped_ptr.h" #include "base/strings/stringprintf.h" #include "base/test/test_timeouts.h" -#include "base/time.h" +#include "base/time/time.h" #include "base/values.h" #include "chrome/common/automation_messages.h" #include "chrome/test/automation/automation_proxy.h" diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h index 3dfb7f1f6b..8abfbfd0f1 100644 --- a/chrome/test/automation/automation_proxy.h +++ b/chrome/test/automation/automation_proxy.h @@ -15,7 +15,7 @@ #include "base/synchronization/waitable_event.h" #include "base/threading/platform_thread.h" #include "base/threading/thread.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/automation_constants.h" #include "chrome/test/automation/automation_handle_tracker.h" diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc index eade432ce3..bf1ad34fe8 100644 --- a/chrome/test/automation/browser_proxy.cc +++ b/chrome/test/automation/browser_proxy.cc @@ -9,7 +9,7 @@ #include "base/json/json_reader.h" #include "base/logging.h" #include "base/threading/platform_thread.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/common/automation_constants.h" #include "chrome/common/automation_messages.h" #include "chrome/test/automation/automation_proxy.h" diff --git a/chrome/test/automation/proxy_launcher.cc b/chrome/test/automation/proxy_launcher.cc index 2a81cef1c0..4b40cc18b2 100644 --- a/chrome/test/automation/proxy_launcher.cc +++ b/chrome/test/automation/proxy_launcher.cc @@ -559,7 +559,7 @@ bool NamedProxyLauncher::InitializeConnection(const LaunchState& state, #if defined(OS_POSIX) // Because we are waiting on the existence of the testing file below, // make sure there isn't one already there before browser launch. - if (!file_util::Delete(base::FilePath(channel_id_), false)) { + if (!base::Delete(base::FilePath(channel_id_), false)) { LOG(ERROR) << "Failed to delete " << channel_id_; return false; } diff --git a/chrome/test/automation/proxy_launcher.h b/chrome/test/automation/proxy_launcher.h index 9ad091f0ae..d638461596 100644 --- a/chrome/test/automation/proxy_launcher.h +++ b/chrome/test/automation/proxy_launcher.h @@ -14,7 +14,7 @@ #include "base/files/scoped_temp_dir.h" #include "base/memory/scoped_ptr.h" #include "base/process.h" -#include "base/time.h" +#include "base/time/time.h" class AutomationProxy; diff --git a/chrome/test/base/chrome_process_util.cc b/chrome/test/base/chrome_process_util.cc index 09ab2c8fe6..26097a6f97 100644 --- a/chrome/test/base/chrome_process_util.cc +++ b/chrome/test/base/chrome_process_util.cc @@ -10,7 +10,7 @@ #include "base/command_line.h" #include "base/process_util.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/common/chrome_constants.h" #include "chrome/test/base/test_switches.h" #include "content/public/common/result_codes.h" @@ -18,39 +18,9 @@ using base::TimeDelta; using base::TimeTicks; -void TerminateAllChromeProcesses(const ChromeProcessList& process_pids) { - ChromeProcessList::const_iterator it; - for (it = process_pids.begin(); it != process_pids.end(); ++it) { - base::ProcessHandle handle; - if (!base::OpenProcessHandle(*it, &handle)) { - // Ignore processes for which we can't open the handle. We don't - // guarantee that all processes will terminate, only try to do so. - continue; - } - - base::KillProcess(handle, content::RESULT_CODE_KILLED, true); - base::CloseProcessHandle(handle); - } -} - -class ChildProcessFilter : public base::ProcessFilter { - public: - explicit ChildProcessFilter(base::ProcessId parent_pid) - : parent_pids_(&parent_pid, (&parent_pid) + 1) {} - - explicit ChildProcessFilter(const std::vector<base::ProcessId>& parent_pids) - : parent_pids_(parent_pids.begin(), parent_pids.end()) {} - - virtual bool Includes(const base::ProcessEntry& entry) const OVERRIDE { - return parent_pids_.find(entry.parent_pid()) != parent_pids_.end(); - } - - private: - const std::set<base::ProcessId> parent_pids_; - - DISALLOW_COPY_AND_ASSIGN(ChildProcessFilter); -}; +namespace { +// Returns the executable name of the current Chrome browser process. const base::FilePath::CharType* GetRunningBrowserExecutableName() { const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); if (cmd_line->HasSwitch(switches::kEnableChromiumBranding)) @@ -58,6 +28,7 @@ const base::FilePath::CharType* GetRunningBrowserExecutableName() { return chrome::kBrowserProcessExecutableName; } +// Returns the executable name of the current Chrome helper process. std::vector<base::FilePath::StringType> GetRunningHelperExecutableNames() { base::FilePath::StringType name; const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); @@ -86,6 +57,41 @@ std::vector<base::FilePath::StringType> GetRunningHelperExecutableNames() { return names; } +} // namespace + +void TerminateAllChromeProcesses(const ChromeProcessList& process_pids) { + ChromeProcessList::const_iterator it; + for (it = process_pids.begin(); it != process_pids.end(); ++it) { + base::ProcessHandle handle; + if (!base::OpenProcessHandle(*it, &handle)) { + // Ignore processes for which we can't open the handle. We don't + // guarantee that all processes will terminate, only try to do so. + continue; + } + + base::KillProcess(handle, content::RESULT_CODE_KILLED, true); + base::CloseProcessHandle(handle); + } +} + +class ChildProcessFilter : public base::ProcessFilter { + public: + explicit ChildProcessFilter(base::ProcessId parent_pid) + : parent_pids_(&parent_pid, (&parent_pid) + 1) {} + + explicit ChildProcessFilter(const std::vector<base::ProcessId>& parent_pids) + : parent_pids_(parent_pids.begin(), parent_pids.end()) {} + + virtual bool Includes(const base::ProcessEntry& entry) const OVERRIDE { + return parent_pids_.find(entry.parent_pid()) != parent_pids_.end(); + } + + private: + const std::set<base::ProcessId> parent_pids_; + + DISALLOW_COPY_AND_ASSIGN(ChildProcessFilter); +}; + ChromeProcessList GetRunningChromeProcesses(base::ProcessId browser_pid) { const base::FilePath::CharType* executable_name = GetRunningBrowserExecutableName(); diff --git a/chrome/test/base/chrome_process_util.h b/chrome/test/base/chrome_process_util.h index aaad5c1023..a3f558abe5 100644 --- a/chrome/test/base/chrome_process_util.h +++ b/chrome/test/base/chrome_process_util.h @@ -12,12 +12,6 @@ typedef std::vector<base::ProcessId> ChromeProcessList; -// Returns the executable name of the current Chrome browser process. -const base::FilePath::CharType* GetRunningBrowserExecutableName(); - -// Returns the executable name of the current Chrome helper process. -const base::FilePath::CharType* GetRunningHelperExecutableName(); - // Returns a vector of PIDs of all chrome processes (main and renderers etc) // based on |browser_pid|, the PID of the main browser process. ChromeProcessList GetRunningChromeProcesses(base::ProcessId browser_pid); diff --git a/chrome/test/base/chrome_test_launcher.cc b/chrome/test/base/chrome_test_launcher.cc index d1a25e0891..deae8ba044 100644 --- a/chrome/test/base/chrome_test_launcher.cc +++ b/chrome/test/base/chrome_test_launcher.cc @@ -47,17 +47,11 @@ #include "ash/test/ui_controls_factory_ash.h" #endif -const char kEmptyTestName[] = "InProcessBrowserTest.Empty"; - class ChromeTestLauncherDelegate : public content::TestLauncherDelegate { public: ChromeTestLauncherDelegate() {} virtual ~ChromeTestLauncherDelegate() {} - virtual std::string GetEmptyTestName() OVERRIDE { - return kEmptyTestName; - } - virtual int RunTestSuite(int argc, char** argv) OVERRIDE { return ChromeTestSuite(argc, argv).Run(); } diff --git a/chrome/test/base/chrome_test_suite.cc b/chrome/test/base/chrome_test_suite.cc index d9fac002e2..bb25ee361f 100644 --- a/chrome/test/base/chrome_test_suite.cc +++ b/chrome/test/base/chrome_test_suite.cc @@ -152,8 +152,10 @@ class ChromeTestSuiteInitializer : public testing::EmptyTestEventListener { virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { if (g_browser_process) { - delete g_browser_process; + BrowserProcess* browser_process = g_browser_process; + // g_browser_process must be NULL during its own destruction. g_browser_process = NULL; + delete browser_process; } // TODO(ios): Bring this back once ChromeContentBrowserClient is building. diff --git a/chrome/test/base/empty_browser_test.cc b/chrome/test/base/empty_browser_test.cc deleted file mode 100644 index 15ab7d48ef..0000000000 --- a/chrome/test/base/empty_browser_test.cc +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) 2012 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/in_process_browser_test.h" - -// An empty test (it starts up and shuts down the browser as part of its -// setup and teardown) used to prefetch all of the browser code into memory. -IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, Empty) { -} diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc index 5cdbf8f4bc..46cd611ed4 100644 --- a/chrome/test/base/in_process_browser_test.cc +++ b/chrome/test/base/in_process_browser_test.cc @@ -5,6 +5,7 @@ #include "chrome/test/base/in_process_browser_test.h" #include "base/auto_reset.h" +#include "base/basictypes.h" #include "base/bind.h" #include "base/command_line.h" #include "base/file_util.h" @@ -13,6 +14,7 @@ #include "base/path_service.h" #include "base/strings/string_number_conversions.h" #include "base/test/test_file_util.h" +#include "base/threading/non_thread_safe.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/google/google_util.h" #include "chrome/browser/io_thread.h" @@ -23,6 +25,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/browser_list_observer.h" #include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" @@ -36,6 +39,7 @@ #include "chrome/renderer/chrome_content_renderer_client.h" #include "chrome/test/base/chrome_test_suite.h" #include "chrome/test/base/test_launcher_utils.h" +#include "chrome/test/base/test_switches.h" #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/ui_test_utils.h" #include "content/public/browser/notification_service.h" @@ -45,6 +49,7 @@ #include "content/public/test/test_launcher.h" #include "content/public/test/test_navigation_observer.h" #include "net/dns/mock_host_resolver.h" +#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/spawned_test_server/spawned_test_server.h" #include "ui/compositor/compositor_switches.h" @@ -54,6 +59,15 @@ #include "base/mac/scoped_nsautorelease_pool.h" #endif +#if defined(OS_WIN) && defined(USE_AURA) +#include "base/win/scoped_com_initializer.h" +#include "base/win/windows_version.h" +#include "ui/base/win/atl_module.h" +#include "ui/compositor/compositor_setup.h" +#include "win8/test/metro_registration_helper.h" +#include "win8/test/test_registrar_constants.h" +#endif + #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) #include "chrome/browser/captive_portal/captive_portal_service.h" #endif @@ -67,11 +81,44 @@ const char kBrowserTestType[] = "browser"; base::LazyInstance<chrome::ChromeContentRendererClient>::Leaky g_chrome_content_renderer_client = LAZY_INSTANCE_INITIALIZER; +// A BrowserListObserver that makes sure that all browsers created are on the +// |allowed_desktop_|. +class SingleDesktopTestObserver : public chrome::BrowserListObserver, + public base::NonThreadSafe { + public: + explicit SingleDesktopTestObserver(chrome::HostDesktopType allowed_desktop); + virtual ~SingleDesktopTestObserver(); + + // chrome::BrowserListObserver: + virtual void OnBrowserAdded(Browser* browser) OVERRIDE; + + private: + chrome::HostDesktopType allowed_desktop_; + + DISALLOW_COPY_AND_ASSIGN(SingleDesktopTestObserver); +}; + +SingleDesktopTestObserver::SingleDesktopTestObserver( + chrome::HostDesktopType allowed_desktop) + : allowed_desktop_(allowed_desktop) { + BrowserList::AddObserver(this); +} + +SingleDesktopTestObserver::~SingleDesktopTestObserver() { + BrowserList::RemoveObserver(this); +} + +void SingleDesktopTestObserver::OnBrowserAdded(Browser* browser) { + CHECK(CalledOnValidThread()); + CHECK_EQ(browser->host_desktop_type(), allowed_desktop_); +} + } // namespace InProcessBrowserTest::InProcessBrowserTest() : browser_(NULL), - exit_when_last_browser_closes_(true) + exit_when_last_browser_closes_(true), + multi_desktop_test_(false) #if defined(OS_MACOSX) , autorelease_pool_(NULL) #endif // OS_MACOSX @@ -89,6 +136,10 @@ InProcessBrowserTest::InProcessBrowserTest() CHECK(PathService::Override(base::FILE_EXE, chrome_path)); #endif // defined(OS_MACOSX) CreateTestServer(base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); + base::FilePath src_dir; + CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)); + embedded_test_server()->ServeFilesFromDirectory( + src_dir.AppendASCII("chrome/test/data")); } InProcessBrowserTest::~InProcessBrowserTest() { @@ -98,8 +149,10 @@ void InProcessBrowserTest::SetUp() { // Undo TestingBrowserProcess creation in ChromeTestSuite. // TODO(phajdan.jr): Extract a smaller test suite so we don't need this. DCHECK(g_browser_process); - delete g_browser_process; + BrowserProcess* old_browser_process = g_browser_process; + // g_browser_process must be NULL during its own destruction. g_browser_process = NULL; + delete old_browser_process; CommandLine* command_line = CommandLine::ForCurrentProcess(); // Allow subclasses to change the command line before running any tests. @@ -159,6 +212,18 @@ void InProcessBrowserTest::SetUp() { google_util::SetMockLinkDoctorBaseURLForTesting(); +#if defined(OS_WIN) && defined(USE_AURA) + if (base::win::GetVersion() >= base::win::VERSION_WIN8 && + CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) { + com_initializer_.reset(new base::win::ScopedCOMInitializer()); + ui::win::CreateATLModuleIfNeeded(); + ASSERT_TRUE(win8::MakeTestDefaultBrowserSynchronously()); + + // Ash browser tests need the real compositor. + ui::DisableTestCompositor(); + } +#endif + BrowserTestBase::SetUp(); } @@ -169,6 +234,17 @@ void InProcessBrowserTest::PrepareTestCommandLine(CommandLine* command_line) { // This is a Browser test. command_line->AppendSwitchASCII(switches::kTestType, kBrowserTestType); +#if defined(OS_WIN) && defined(USE_AURA) + if (command_line->HasSwitch(switches::kAshBrowserTests)) { + command_line->AppendSwitchNative(switches::kViewerLaunchViaAppId, + win8::test::kDefaultTestAppUserModelId); + // Ash already launches with a single browser opened, add kSilentLaunch to + // make sure StartupBrowserCreator doesn't attempt to launch a browser on + // the native desktop on startup. + command_line->AppendSwitch(switches::kSilentLaunch); + } +#endif + #if defined(OS_MACOSX) // Explicitly set the path of the binary used for child processes, otherwise // they'll try to use browser_tests which doesn't contain ChromeMain. @@ -212,6 +288,9 @@ bool InProcessBrowserTest::CreateUserDataDirectory() { void InProcessBrowserTest::TearDown() { DCHECK(!g_browser_process); +#if defined(OS_WIN) && defined(USE_AURA) + com_initializer_.reset(); +#endif BrowserTestBase::TearDown(); } @@ -243,7 +322,7 @@ bool InProcessBrowserTest::SetUpUserDataDirectory() { // finish loading and shows the browser. Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) { Browser* browser = new Browser( - Browser::CreateParams(profile, chrome::HOST_DESKTOP_TYPE_NATIVE)); + Browser::CreateParams(profile, chrome::GetActiveDesktop())); AddBlankTabAndShow(browser); return browser; } @@ -252,7 +331,7 @@ Browser* InProcessBrowserTest::CreateIncognitoBrowser() { // Create a new browser with using the incognito profile. Browser* incognito = new Browser( Browser::CreateParams(browser()->profile()->GetOffTheRecordProfile(), - chrome::HOST_DESKTOP_TYPE_NATIVE)); + chrome::GetActiveDesktop())); AddBlankTabAndShow(incognito); return incognito; } @@ -260,7 +339,7 @@ Browser* InProcessBrowserTest::CreateIncognitoBrowser() { Browser* InProcessBrowserTest::CreateBrowserForPopup(Profile* profile) { Browser* browser = new Browser(Browser::CreateParams(Browser::TYPE_POPUP, profile, - chrome::HOST_DESKTOP_TYPE_NATIVE)); + chrome::GetActiveDesktop())); AddBlankTabAndShow(browser); return browser; } @@ -271,7 +350,7 @@ Browser* InProcessBrowserTest::CreateBrowserForApp( Browser* browser = new Browser( Browser::CreateParams::CreateForApp( Browser::TYPE_POPUP, app_name, gfx::Rect(), profile, - chrome::HOST_DESKTOP_TYPE_NATIVE)); + chrome::GetActiveDesktop())); AddBlankTabAndShow(browser); return browser; } @@ -327,11 +406,18 @@ void InProcessBrowserTest::RunTestOnMainThreadLoop() { autorelease_pool_->Recycle(); #endif - // Browser tests do not support multi-desktop for now. - const BrowserList* native_browser_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); - if (!native_browser_list->empty()) { - browser_ = native_browser_list->get(0); + chrome::HostDesktopType active_desktop = chrome::GetActiveDesktop(); + // Self-adds/removes itself from the BrowserList observers. + scoped_ptr<SingleDesktopTestObserver> single_desktop_test_observer; + if (!multi_desktop_test_) { + single_desktop_test_observer.reset( + new SingleDesktopTestObserver(active_desktop)); + } + + const BrowserList* active_browser_list = + BrowserList::GetInstance(active_desktop); + if (!active_browser_list->empty()) { + browser_ = active_browser_list->get(0); #if defined(USE_ASH) // There are cases where windows get created maximized by default. if (browser_->window()->IsMaximized()) @@ -370,7 +456,12 @@ void InProcessBrowserTest::RunTestOnMainThreadLoop() { content::RunAllPendingInMessageLoop(); QuitBrowsers(); - CHECK(native_browser_list->empty()); + // All BrowserLists should be empty at this point. + for (chrome::HostDesktopType t = chrome::HOST_DESKTOP_TYPE_FIRST; + t < chrome::HOST_DESKTOP_TYPE_COUNT; + t = static_cast<chrome::HostDesktopType>(t + 1)) { + CHECK(BrowserList::GetInstance(t)->empty()) << t; + } } void InProcessBrowserTest::QuitBrowsers() { diff --git a/chrome/test/base/in_process_browser_test.h b/chrome/test/base/in_process_browser_test.h index db5977f9be..53ecfc1d3f 100644 --- a/chrome/test/base/in_process_browser_test.h +++ b/chrome/test/base/in_process_browser_test.h @@ -18,13 +18,19 @@ #include "chrome/browser/chromeos/cros/cros_library.h" #endif // defined(OS_CHROMEOS) -#if defined(OS_MACOSX) namespace base { +#if defined(OS_MACOSX) namespace mac { class ScopedNSAutoreleasePool; } // namespace mac +#endif // defined(OS_MACOSX) + +#if defined(OS_WIN) && defined(USE_AURA) +namespace win { +class ScopedCOMInitializer; +} +#endif // defined(OS_WIN) && defined(USE_AURA) } // namespace base -#endif // OS_MACOSX class Browser; class CommandLine; @@ -177,6 +183,11 @@ class InProcessBrowserTest : public content::BrowserTestBase { exit_when_last_browser_closes_ = value; } + // This must be called before RunTestOnMainThreadLoop() to have any effect. + void set_multi_desktop_test(bool multi_desktop_test) { + multi_desktop_test_ = multi_desktop_test; + } + private: // Creates a user data directory for the test if one is needed. Returns true // if successful. @@ -202,6 +213,10 @@ class InProcessBrowserTest : public content::BrowserTestBase { // True if we should exit the tests after the last browser instance closes. bool exit_when_last_browser_closes_; + // True if this is a multi-desktop test (in which case this browser test will + // not ensure that Browsers are only created on the tested desktop). + bool multi_desktop_test_; + #if defined(OS_CHROMEOS) chromeos::ScopedStubCrosEnabler stub_cros_enabler_; #endif // defined(OS_CHROMEOS) @@ -209,6 +224,10 @@ class InProcessBrowserTest : public content::BrowserTestBase { #if defined(OS_MACOSX) base::mac::ScopedNSAutoreleasePool* autorelease_pool_; #endif // OS_MACOSX + +#if defined(OS_WIN) && defined(USE_AURA) + scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_; +#endif }; #endif // CHROME_TEST_BASE_IN_PROCESS_BROWSER_TEST_H_ diff --git a/chrome/test/base/interactive_test_utils_win.cc b/chrome/test/base/interactive_test_utils_win.cc index 328a02534c..ec7e28543f 100644 --- a/chrome/test/base/interactive_test_utils_win.cc +++ b/chrome/test/base/interactive_test_utils_win.cc @@ -8,7 +8,7 @@ #include "base/logging.h" #include "base/path_service.h" #include "base/strings/stringprintf.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/browser/ui/window_snapshot/window_snapshot.h" #include "ui/base/test/ui_controls.h" #include "ui/base/win/foreground_helper.h" diff --git a/chrome/test/base/model_test_utils.cc b/chrome/test/base/model_test_utils.cc deleted file mode 100644 index 917c8d2659..0000000000 --- a/chrome/test/base/model_test_utils.cc +++ /dev/null @@ -1,84 +0,0 @@ -// 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 "chrome/test/base/model_test_utils.h" - -#include "base/strings/utf_string_conversions.h" -#include "chrome/browser/bookmarks/bookmark_model.h" -#include "googleurl/src/gurl.h" - -namespace model_test_utils { - -std::string ModelStringFromNode(const BookmarkNode* node) { - // Since the children of the node are not available as a vector, - // we'll just have to do it the hard way. - int child_count = node->child_count(); - std::string child_string; - for (int i = 0; i < child_count; ++i) { - const BookmarkNode* child = node->GetChild(i); - if (child->is_folder()) { - child_string += UTF16ToUTF8(child->GetTitle()) + ":[ " + - ModelStringFromNode(child) + "] "; - } else { - child_string += UTF16ToUTF8(child->GetTitle()) + " "; - } - } - return child_string; -} - -// Helper function which does the actual work of creating the nodes for -// a particular level in the hierarchy. -std::string::size_type AddNodesFromString(BookmarkModel* model, - const BookmarkNode* node, - const std::string& model_string, - std::string::size_type start_pos) { - DCHECK(node); - int index = node->child_count(); - static const std::string folder_tell(":["); - std::string::size_type end_pos = model_string.find(' ', start_pos); - while (end_pos != std::string::npos) { - std::string::size_type part_length = end_pos - start_pos; - std::string node_name = model_string.substr(start_pos, part_length); - // Are we at the end of a folder group? - if (node_name != "]") { - // No, is it a folder? - std::string tell; - if (part_length > 2) - tell = node_name.substr(part_length - 2, 2); - if (tell == folder_tell) { - node_name = node_name.substr(0, part_length - 2); - const BookmarkNode* new_node = - model->AddFolder(node, index, UTF8ToUTF16(node_name)); - end_pos = AddNodesFromString(model, new_node, model_string, - end_pos + 1); - } else { - std::string url_string("http://"); - url_string += std::string(node_name.begin(), node_name.end()); - url_string += ".com"; - model->AddURL(node, index, UTF8ToUTF16(node_name), GURL(url_string)); - ++end_pos; - } - ++index; - start_pos = end_pos; - end_pos = model_string.find(' ', start_pos); - } else { - ++end_pos; - break; - } - } - return end_pos; -} - -void AddNodesFromModelString(BookmarkModel* model, - const BookmarkNode* node, - const std::string& model_string) { - DCHECK(node); - const std::string folder_tell(":["); - std::string::size_type start_pos = 0; - std::string::size_type end_pos = - AddNodesFromString(model, node, model_string, start_pos); - DCHECK(end_pos == std::string::npos); -} - -} // namespace model_test_utils diff --git a/chrome/test/base/model_test_utils.h b/chrome/test/base/model_test_utils.h deleted file mode 100644 index ee58a8abfc..0000000000 --- a/chrome/test/base/model_test_utils.h +++ /dev/null @@ -1,43 +0,0 @@ -// 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 CHROME_TEST_BASE_MODEL_TEST_UTILS_H_ -#define CHROME_TEST_BASE_MODEL_TEST_UTILS_H_ - -#include <string> - -class BookmarkModel; -class BookmarkNode; - -namespace model_test_utils { - -// Return the descendants of |node| as a string useful for verifying node -// modifications. The format of the resulting string is: -// -// result = node " " , { node " " } -// node = bookmark title | folder -// folder = folder title ":[ " { node " " } "]" -// bookmark title = (* string with no spaces *) -// folder title = (* string with no spaces *) -// -// Example: "a f1:[ b d c ] d f2:[ e f g ] h " -// -// (Logically, we should use |string16|s, but it's more convenient for test -// purposes to use (UTF-8) |std::string|s.) -std::string ModelStringFromNode(const BookmarkNode* node); - -// Create and add the node hierarchy specified by |nodeString| to the -// bookmark node given by |node|. The string has the same format as -// specified for ModelStringFromNode. The new nodes added to |node| -// are appended to the end of node's existing subnodes, if any. -// |model| must be the model of which |node| is a member. -// NOTE: The string format is very rigid and easily broken if not followed -// exactly (since we're using a very simple parser). -void AddNodesFromModelString(BookmarkModel* model, - const BookmarkNode* node, - const std::string& model_string); - -} // namespace model_test_utils - -#endif // CHROME_TEST_BASE_MODEL_TEST_UTILS_H_ diff --git a/chrome/test/base/test_switches.cc b/chrome/test/base/test_switches.cc index c5e3c99a70..e52da44dfc 100644 --- a/chrome/test/base/test_switches.cc +++ b/chrome/test/base/test_switches.cc @@ -4,22 +4,23 @@ #include "chrome/test/base/test_switches.h" +namespace switches { + // Also emit full event trace logs for successful tests. -const char switches::kAlsoEmitSuccessLogs[] = "also-emit-success-logs"; +const char kAlsoEmitSuccessLogs[] = "also-emit-success-logs"; // Extra flags that the test should pass to launched browser process. -const char switches::kExtraChromeFlags[] = "extra-chrome-flags"; +const char kExtraChromeFlags[] = "extra-chrome-flags"; // Enable Chromium branding of the executable. -const char switches::kEnableChromiumBranding[] = "enable-chromium-branding"; +const char kEnableChromiumBranding[] = "enable-chromium-branding"; // Enable displaying error dialogs (for debugging). -const char switches::kEnableErrorDialogs[] = "enable-errdialogs"; - -// Number of iterations that page cycler tests will run. -const char switches::kPageCyclerIterations[] = "page-cycler-iterations"; +const char kEnableErrorDialogs[] = "enable-errdialogs"; -// Name of channel used to connect to Chrome -// when using the named testing interface. -const char switches::kTestingChannel[] = "testing-channel"; +#if defined(OS_WIN) && defined(USE_AURA) +// Force browser tests to run in Ash/Metro on Windows 8. +const char kAshBrowserTests[] = "ash-browsertests"; +#endif +} // namespace switches diff --git a/chrome/test/base/test_switches.h b/chrome/test/base/test_switches.h index c37e71992d..c96107e047 100644 --- a/chrome/test/base/test_switches.h +++ b/chrome/test/base/test_switches.h @@ -5,6 +5,8 @@ #ifndef CHROME_TEST_BASE_TEST_SWITCHES_H_ #define CHROME_TEST_BASE_TEST_SWITCHES_H_ +#include "build/build_config.h" + namespace switches { // All switches in alphabetical order. The switches should be documented @@ -13,8 +15,10 @@ extern const char kAlsoEmitSuccessLogs[]; extern const char kExtraChromeFlags[]; extern const char kEnableChromiumBranding[]; extern const char kEnableErrorDialogs[]; -extern const char kPageCyclerIterations[]; -extern const char kTestingChannel[]; + +#if defined(OS_WIN) && defined(USE_AURA) +extern const char kAshBrowserTests[]; +#endif } // namespace switches diff --git a/chrome/test/base/testing_browser_process.cc b/chrome/test/base/testing_browser_process.cc index 3fe39f2b10..224e623136 100644 --- a/chrome/test/base/testing_browser_process.cc +++ b/chrome/test/base/testing_browser_process.cc @@ -7,6 +7,7 @@ #include "base/prefs/pref_service.h" #include "base/strings/string_util.h" #include "build/build_config.h" +#include "chrome/browser/background/background_mode_manager.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/bookmarks/bookmark_prompt_controller.h" @@ -55,6 +56,10 @@ TestingBrowserProcess::~TestingBrowserProcess() { #if defined(ENABLE_CONFIGURATION_POLICY) SetBrowserPolicyConnector(NULL); #endif + + // Destructors for some objects owned by TestingBrowserProcess will use + // g_browser_process if it is not NULL, so it must be NULL before proceeding. + DCHECK_EQ(static_cast<BrowserProcess*>(NULL), g_browser_process); } void TestingBrowserProcess::ResourceDispatcherHostCreated() { @@ -149,6 +154,11 @@ BackgroundModeManager* TestingBrowserProcess::background_mode_manager() { return NULL; } +void TestingBrowserProcess::set_background_mode_manager_for_test( + scoped_ptr<BackgroundModeManager> manager) { + NOTREACHED(); +} + StatusTray* TestingBrowserProcess::status_tray() { return NULL; } diff --git a/chrome/test/base/testing_browser_process.h b/chrome/test/base/testing_browser_process.h index 300f192636..983d766541 100644 --- a/chrome/test/base/testing_browser_process.h +++ b/chrome/test/base/testing_browser_process.h @@ -62,6 +62,8 @@ class TestingBrowserProcess : public BrowserProcess { virtual GpuModeManager* gpu_mode_manager() OVERRIDE; virtual RenderWidgetSnapshotTaker* GetRenderWidgetSnapshotTaker() OVERRIDE; virtual BackgroundModeManager* background_mode_manager() OVERRIDE; + virtual void set_background_mode_manager_for_test( + scoped_ptr<BackgroundModeManager> manager) OVERRIDE; virtual StatusTray* status_tray() OVERRIDE; virtual SafeBrowsingService* safe_browsing_service() OVERRIDE; virtual safe_browsing::ClientSideDetectionService* diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc index a5bdae8fb2..5ee917f316 100644 --- a/chrome/test/base/testing_profile.cc +++ b/chrome/test/base/testing_profile.cc @@ -269,7 +269,7 @@ void TestingProfile::CreateTempProfileDir() { base::FilePath fallback_dir( system_tmp_dir.AppendASCII("TestingProfilePath")); - file_util::Delete(fallback_dir, true); + base::Delete(fallback_dir, true); file_util::CreateDirectory(fallback_dir); if (!temp_dir_.Set(fallback_dir)) { // That shouldn't happen, but if it does, try to recover. @@ -360,7 +360,7 @@ void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { if (delete_file) { base::FilePath path = GetPath(); path = path.Append(chrome::kHistoryFilename); - file_util::Delete(path, false); + base::Delete(path, false); } // This will create and init the history service. HistoryService* history_service = static_cast<HistoryService*>( @@ -429,7 +429,7 @@ static BrowserContextKeyedService* BuildBookmarkModel( void TestingProfile::CreateBookmarkModel(bool delete_file) { if (delete_file) { base::FilePath path = GetPath().Append(chrome::kBookmarksFileName); - file_util::Delete(path, false); + base::Delete(path, false); } // This will create a bookmark model. BookmarkModel* bookmark_service = static_cast<BookmarkModel*>( diff --git a/chrome/test/base/testing_profile_manager.cc b/chrome/test/base/testing_profile_manager.cc index 9871d4a4ad..5a5f6202af 100644 --- a/chrome/test/base/testing_profile_manager.cc +++ b/chrome/test/base/testing_profile_manager.cc @@ -5,8 +5,10 @@ #include "chrome/test/base/testing_profile_manager.h" #include "base/files/file_path.h" -#include "base/memory/scoped_ptr.h" +#include "base/memory/ref_counted.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/browser/extensions/extension_special_storage_policy.h" +#include "chrome/browser/prefs/pref_service_syncable.h" #include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/test/base/testing_browser_process.h" @@ -45,6 +47,7 @@ bool TestingProfileManager::SetUp() { TestingProfile* TestingProfileManager::CreateTestingProfile( const std::string& profile_name, + scoped_ptr<PrefServiceSyncable> prefs, const string16& user_name, int avatar_id) { DCHECK(called_set_up_); @@ -54,7 +57,11 @@ TestingProfile* TestingProfileManager::CreateTestingProfile( profile_path = profile_path.AppendASCII(profile_name); // Create the profile and register it. - TestingProfile* profile = new TestingProfile(profile_path); + TestingProfile* profile = new TestingProfile( + profile_path, + NULL, + scoped_refptr<ExtensionSpecialStoragePolicy>(), + prefs.Pass()); profile_manager_->AddProfile(profile); // Takes ownership. // Update the user metadata. @@ -71,7 +78,8 @@ TestingProfile* TestingProfileManager::CreateTestingProfile( TestingProfile* TestingProfileManager::CreateTestingProfile( const std::string& name) { DCHECK(called_set_up_); - return CreateTestingProfile(name, UTF8ToUTF16(name), 0); + return CreateTestingProfile(name, scoped_ptr<PrefServiceSyncable>(), + UTF8ToUTF16(name), 0); } void TestingProfileManager::DeleteTestingProfile(const std::string& name) { diff --git a/chrome/test/base/testing_profile_manager.h b/chrome/test/base/testing_profile_manager.h index f6ae1f7a5f..7a4205c3ea 100644 --- a/chrome/test/base/testing_profile_manager.h +++ b/chrome/test/base/testing_profile_manager.h @@ -10,9 +10,11 @@ #include "base/compiler_specific.h" #include "base/files/scoped_temp_dir.h" +#include "base/memory/scoped_ptr.h" #include "base/strings/string16.h" #include "chrome/test/base/scoped_testing_local_state.h" +class PrefServiceSyncable; class ProfileInfoCache; class ProfileManager; class TestingBrowserProcess; @@ -38,11 +40,14 @@ class TestingProfileManager { // Creates a new TestingProfile whose data lives in a directory related to // profile_name, which is a non-user-visible key for the test environment. + // |prefs| is the PrefService used by the profile. If it is NULL, the profile + // creates a PrefService on demand. // |user_name| and |avatar_id| are passed along to the ProfileInfoCache and // provide the user-visible profile metadata. This will register the // TestingProfile with the profile subsystem as well. The subsystem owns the // Profile and returns a weak pointer. TestingProfile* CreateTestingProfile(const std::string& profile_name, + scoped_ptr<PrefServiceSyncable> prefs, const string16& user_name, int avatar_id); diff --git a/chrome/test/base/tracing.h b/chrome/test/base/tracing.h index 0dd21b881e..bff5afa0c2 100644 --- a/chrome/test/base/tracing.h +++ b/chrome/test/base/tracing.h @@ -8,7 +8,7 @@ #include <string> #include "base/compiler_specific.h" -#include "base/time.h" +#include "base/time/time.h" namespace tracing { diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc index be43fa14f5..61f8b269eb 100644 --- a/chrome/test/base/ui_test_utils.cc +++ b/chrome/test/base/ui_test_utils.cc @@ -21,7 +21,7 @@ #include "base/prefs/pref_service.h" #include "base/strings/utf_string_conversions.h" #include "base/test/test_timeouts.h" -#include "base/time.h" +#include "base/time/time.h" #include "base/values.h" #include "chrome/browser/autocomplete/autocomplete_controller.h" #include "chrome/browser/bookmarks/bookmark_model.h" @@ -158,11 +158,10 @@ Browser* WaitForBrowserNotInSet(std::set<Browser*> excluded_browsers) { } Browser* OpenURLOffTheRecord(Profile* profile, const GURL& url) { - chrome::OpenURLOffTheRecord(profile, url, chrome::HOST_DESKTOP_TYPE_NATIVE); + chrome::HostDesktopType active_desktop = chrome::GetActiveDesktop(); + chrome::OpenURLOffTheRecord(profile, url, active_desktop); Browser* browser = chrome::FindTabbedBrowser( - profile->GetOffTheRecordProfile(), - false, - chrome::HOST_DESKTOP_TYPE_NATIVE); + profile->GetOffTheRecordProfile(), false, active_desktop); WaitForNavigations( &browser->tab_strip_model()->GetActiveWebContents()->GetController(), 1); diff --git a/chrome/test/base/view_event_test_base.cc b/chrome/test/base/view_event_test_base.cc index f379c400d9..62a7b4e760 100644 --- a/chrome/test/base/view_event_test_base.cc +++ b/chrome/test/base/view_event_test_base.cc @@ -32,7 +32,6 @@ #if defined(OS_CHROMEOS) #include "chromeos/audio/cras_audio_handler.h" -#include "chromeos/power/power_manager_handler.h" #endif namespace { @@ -108,7 +107,6 @@ void ViewEventTestBase::SetUp() { message_center::MessageCenter::Initialize(); #if defined(OS_CHROMEOS) chromeos::CrasAudioHandler::InitializeForTesting(); - chromeos::PowerManagerHandler::Initialize(); #endif ash::Shell::CreateInstance(new ash::test::TestShellDelegate()); context = ash::Shell::GetPrimaryRootWindow(); @@ -138,7 +136,6 @@ void ViewEventTestBase::TearDown() { #else ash::Shell::DeleteInstance(); #if defined(OS_CHROMEOS) - chromeos::PowerManagerHandler::Shutdown(); chromeos::CrasAudioHandler::Shutdown(); #endif // Ash Shell can't just live on its own without a browser process, we need to diff --git a/chrome/test/chromedriver/README.txt b/chrome/test/chromedriver/README.txt index ab9e95cc37..35f0d5466f 100644 --- a/chrome/test/chromedriver/README.txt +++ b/chrome/test/chromedriver/README.txt @@ -5,18 +5,21 @@ ChromeDriver is an implementation of the WebDriver standard, which allows users to automate testing of their website across browsers. =====Getting started===== -Build ChromeDriver by building the 'chromedriver2' target. This will create -a shared library in the build folder named 'chromedriver2.dll' (win), -'chromedriver2.so' (mac), or 'libchromedriver2.so' (linux). +Build ChromeDriver by building the 'chromedriver2_server' target. This will +create an executable binary in the build folder named 'chromedriver2_server.exe' +on Windows or 'chromedriver2_server' on Mac and Linux. Once built, ChromeDriver can be used interactively with python. -This can be easily done by running python in this directory (or including -this directory in your PYTHONPATH). +$ export PYTHONPATH=<THIS_DIR>/server:<THIS_DIR>/client $ python +>>> import server >>> import chromedriver ->>> driver = chromedriver.ChromeDriver('/path/to/chromedriver2/library') +>>> cd_server = server.Server('/path/to/chromedriver2_server/executable') +>>> driver = chromedriver.ChromeDriver(cd_server.GetUrl()) >>> driver.Load('http://www.google.com') +>>> driver.Quit() +>>> cd_server.Kill() ChromeDriver will use the system installed Chrome by default. @@ -26,28 +29,16 @@ adb_commands.py and the adb tool from the Android SDK must be set in PATH. For more detailed instructions see the wiki: https://code.google.com/p/chromedriver/wiki/ChromeDriver2forAndroid -NOTE: on 64-bit OSX machines (most modern ones, including laptops) it is -necessary to set the environment variable VERSIONER_PYTHON_PREFER_32_BIT=yes, -because the 'chromedriver2.so' library is 32-bit, while on 64-bit OSX machines -(most modern ones including laptops), python starts as a 64-bit binary by -default and would not be able to load the library. - =====Architecture===== ChromeDriver is shipped separately from Chrome. It controls Chrome out of -process through DevTools (WebKit Inspector). ChromeDriver is a shared library -which exports a few functions for executing WebDriver-standard commands, which -are packaged in JSON. For internal use, a custom python client for ChromeDriver -is available in chromedriver.py, which works on desktop (win/mac/linux) with -the shared library ChromeDriver. - -The ChromeDriver shared library runs commands on the same thread that calls -ExecuteCommand. It doesn't create any additional threads except for the IO -thread. The IO thread is used to keep reading incoming data from Chrome in the -background. +process through DevTools (WebKit Inspector). ChromeDriver is a standalone server +executable which communicates via the WebDriver JSON wire protocol. This can be +used with the open source WebDriver client libraries. -ChromeDriver is also available as a standalone server executable which -communicates via the WebDriver JSON wire protocol. This can be used with the -open source WebDriver client libraries. +When a new session is created, a new thread is started that is dedicated to the +session. All commands for the session runs on this thread. This thread is +stopped when the session is deleted. Besides, there is an IO thread and it is +used to keep reading incoming data from Chrome in the background. =====Code structure===== Code under the 'chrome' subdirectory is intended to be unaware of WebDriver and @@ -67,10 +58,17 @@ Javascript helper scripts. 4) chrome/test/chromedriver/net Code to deal with network communication, such as connection to DevTools. -5) chrome/test/chromedriver/server +5) chrome/test/chromedriver/client +Code for a python client. + +6) chrome/test/chromedriver/server Code for the chromedriver server. +A python wrapper to the chromedriver server. + +7) chrome/test/chromedriver/extension +An extension used for automating the desktop browser. -6) chrome/test/chromedriver/third_party +8) chrome/test/chromedriver/third_party Third party libraries used by chromedriver. =====Testing===== diff --git a/chrome/test/chromedriver/archive.py b/chrome/test/chromedriver/archive.py index 5835a80c2e..9a2aa87c70 100644 --- a/chrome/test/chromedriver/archive.py +++ b/chrome/test/chromedriver/archive.py @@ -6,16 +6,13 @@ import os import platform -import sys import urllib -_THIS_DIR = os.path.abspath(os.path.dirname(__file__)) -sys.path.insert(0, os.path.join(_THIS_DIR, os.pardir, 'pylib')) - -from common import util +import util CHROME_27_REVISION = '190466' CHROME_28_REVISION = '198276' +CHROME_29_REVISION = '208334' _SITE = 'http://commondatastorage.googleapis.com' diff --git a/chrome/test/chromedriver/capabilities.cc b/chrome/test/chromedriver/capabilities.cc index fa5996df59..d5c55f32ef 100644 --- a/chrome/test/chromedriver/capabilities.cc +++ b/chrome/test/chromedriver/capabilities.cc @@ -42,7 +42,9 @@ Status ParseLogPath(const base::Value& option, Capabilities* capabilities) { return Status(kOk); } -Status ParseArgs(const base::Value& option, Capabilities* capabilities) { +Status ParseArgs(bool is_android, + const base::Value& option, + Capabilities* capabilities) { const base::ListValue* args_list = NULL; if (!option.GetAsList(&args_list)) return Status(kUnknownError, "'args' must be a list"); @@ -50,16 +52,20 @@ Status ParseArgs(const base::Value& option, Capabilities* capabilities) { std::string arg_string; if (!args_list->GetString(i, &arg_string)) return Status(kUnknownError, "each argument must be a string"); - size_t separator_index = arg_string.find("="); - if (separator_index != std::string::npos) { - CommandLine::StringType arg_string_native; - if (!args_list->GetString(i, &arg_string_native)) - return Status(kUnknownError, "each argument must be a string"); - capabilities->command.AppendSwitchNative( - arg_string.substr(0, separator_index), - arg_string_native.substr(separator_index + 1)); + if (is_android) { + capabilities->android_args += "--" + arg_string + " "; } else { - capabilities->command.AppendSwitch(arg_string); + size_t separator_index = arg_string.find("="); + if (separator_index != std::string::npos) { + CommandLine::StringType arg_string_native; + if (!args_list->GetString(i, &arg_string_native)) + return Status(kUnknownError, "each argument must be a string"); + capabilities->command.AppendSwitchNative( + arg_string.substr(0, separator_index), + arg_string_native.substr(separator_index + 1)); + } else { + capabilities->command.AppendSwitch(arg_string); + } } } return Status(kOk); @@ -164,7 +170,7 @@ Status ParseProxy(const base::Value& option, Capabilities* capabilities) { return Status(kOk); } -Status ParseDesktopChromeOption( +Status ParseDesktopChromeCapabilities( const base::Value& capability, Capabilities* capabilities) { const base::DictionaryValue* chrome_options = NULL; @@ -176,7 +182,7 @@ Status ParseDesktopChromeOption( parser_map["detach"] = base::Bind(&ParseDetach); parser_map["binary"] = base::Bind(&ParseChromeBinary); parser_map["logPath"] = base::Bind(&ParseLogPath); - parser_map["args"] = base::Bind(&ParseArgs); + parser_map["args"] = base::Bind(&ParseArgs, false); parser_map["prefs"] = base::Bind(&ParsePrefs); parser_map["localState"] = base::Bind(&ParseLocalState); parser_map["extensions"] = base::Bind(&ParseExtensions); @@ -209,15 +215,20 @@ Status ParseAndroidChromeCapabilities(const base::DictionaryValue& desired_caps, return Status(kUnknownError, "'androidPackage' must be a non-empty string"); } - } - const base::Value* device_serial_value; - if (chrome_options_dict->Get("deviceSerial", &device_serial_value)) { - if (!device_serial_value->GetAsString(&capabilities->device_serial) || - capabilities->device_serial.empty()) { - return Status(kUnknownError, - "'deviceSerial' must be a non-empty string"); + const base::Value* device_serial_value; + if (chrome_options_dict->Get("androidDeviceSerial", + &device_serial_value)) { + if (!device_serial_value->GetAsString(&capabilities->device_serial) || + capabilities->device_serial.empty()) { + return Status(kUnknownError, + "'androidDeviceSerial' must be a non-empty string"); + } } + + const base::Value* args_value; + if (chrome_options_dict->Get("args", &args_value)) + return ParseArgs(true, *args_value, capabilities); } } return Status(kOk); @@ -262,7 +273,7 @@ Status Capabilities::Parse(const base::DictionaryValue& desired_caps) { std::map<std::string, Parser> parser_map; parser_map["proxy"] = base::Bind(&ParseProxy); - parser_map["chromeOptions"] = base::Bind(&ParseDesktopChromeOption); + parser_map["chromeOptions"] = base::Bind(&ParseDesktopChromeCapabilities); for (std::map<std::string, Parser>::iterator it = parser_map.begin(); it != parser_map.end(); ++it) { const base::Value* capability = NULL; diff --git a/chrome/test/chromedriver/capabilities.h b/chrome/test/chromedriver/capabilities.h index 723ff10dec..5e22b9a0e0 100644 --- a/chrome/test/chromedriver/capabilities.h +++ b/chrome/test/chromedriver/capabilities.h @@ -34,6 +34,7 @@ struct Capabilities { std::string android_package; std::string device_serial; + std::string android_args; std::string log_path; CommandLine command; diff --git a/chrome/test/chromedriver/chrome/adb.h b/chrome/test/chromedriver/chrome/adb.h index a11f9c2920..24ad7005c6 100644 --- a/chrome/test/chromedriver/chrome/adb.h +++ b/chrome/test/chromedriver/chrome/adb.h @@ -18,7 +18,8 @@ class Adb { virtual Status ForwardPort(const std::string& device_serial, int local_port, const std::string& remote_abstract) = 0; - virtual Status SetChromeFlags(const std::string& device_serial) = 0; + virtual Status SetChromeArgs(const std::string& device_serial, + const std::string& args) = 0; virtual Status CheckAppInstalled(const std::string& device_serial, const std::string& package) = 0; virtual Status ClearAppData(const std::string& device_serial, diff --git a/chrome/test/chromedriver/chrome/adb_impl.cc b/chrome/test/chromedriver/chrome/adb_impl.cc index 0386e29e74..ea98162e04 100644 --- a/chrome/test/chromedriver/chrome/adb_impl.cc +++ b/chrome/test/chromedriver/chrome/adb_impl.cc @@ -15,7 +15,7 @@ #include "base/strings/string_tokenizer.h" #include "base/strings/stringprintf.h" #include "base/synchronization/waitable_event.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/test/chromedriver/chrome/log.h" #include "chrome/test/chromedriver/chrome/status.h" #include "chrome/test/chromedriver/net/adb_client_socket.h" @@ -112,13 +112,12 @@ Status AdbImpl::ForwardPort( device_serial + ": " + response); } -Status AdbImpl::SetChromeFlags(const std::string& device_serial) { +Status AdbImpl::SetChromeArgs(const std::string& device_serial, + const std::string& args) { std::string response; Status status = ExecuteHostShellCommand( device_serial, - "echo chrome --disable-fre --metrics-recording-only " - "--enable-remote-debugging > /data/local/chrome-command-line;" - "echo $?", + "echo chrome " + args + "> /data/local/chrome-command-line; echo $?", &response); if (!status.IsOk()) return status; diff --git a/chrome/test/chromedriver/chrome/adb_impl.h b/chrome/test/chromedriver/chrome/adb_impl.h index 39d376cb16..47f9853fe9 100644 --- a/chrome/test/chromedriver/chrome/adb_impl.h +++ b/chrome/test/chromedriver/chrome/adb_impl.h @@ -31,7 +31,8 @@ class AdbImpl : public Adb { virtual Status ForwardPort(const std::string& device_serial, int local_port, const std::string& remote_abstract) OVERRIDE; - virtual Status SetChromeFlags(const std::string& device_serial) OVERRIDE; + virtual Status SetChromeArgs(const std::string& device_serial, + const std::string& args) OVERRIDE; virtual Status CheckAppInstalled(const std::string& device_serial, const std::string& package) OVERRIDE; virtual Status ClearAppData(const std::string& device_serial, diff --git a/chrome/test/chromedriver/chrome/automation_extension.cc b/chrome/test/chromedriver/chrome/automation_extension.cc index 63ad2230f7..65e035af9d 100644 --- a/chrome/test/chromedriver/chrome/automation_extension.cc +++ b/chrome/test/chromedriver/chrome/automation_extension.cc @@ -4,7 +4,7 @@ #include "chrome/test/chromedriver/chrome/automation_extension.h" -#include "base/time.h" +#include "base/time/time.h" #include "base/values.h" #include "chrome/test/chromedriver/chrome/status.h" #include "chrome/test/chromedriver/chrome/web_view.h" diff --git a/chrome/test/chromedriver/chrome/chrome_desktop_impl.cc b/chrome/test/chromedriver/chrome/chrome_desktop_impl.cc index 08c9b9f68a..c1489bbe5a 100644 --- a/chrome/test/chromedriver/chrome/chrome_desktop_impl.cc +++ b/chrome/test/chromedriver/chrome/chrome_desktop_impl.cc @@ -10,7 +10,7 @@ #include "base/process_util.h" #include "base/sys_info.h" #include "base/threading/platform_thread.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/test/chromedriver/chrome/automation_extension.h" #include "chrome/test/chromedriver/chrome/devtools_client.h" #include "chrome/test/chromedriver/chrome/devtools_http_client.h" diff --git a/chrome/test/chromedriver/chrome/chrome_finder.cc b/chrome/test/chromedriver/chrome/chrome_finder.cc index 406f19fcd9..f2d2079538 100644 --- a/chrome/test/chromedriver/chrome/chrome_finder.cc +++ b/chrome/test/chromedriver/chrome/chrome_finder.cc @@ -25,6 +25,7 @@ namespace { #if defined(OS_WIN) void GetApplicationDirs(std::vector<base::FilePath>* locations) { + std::vector<base::FilePath> installation_locations; // Add user-level location. scoped_ptr<base::Environment> env(base::Environment::Create()); std::string home_dir; @@ -36,15 +37,24 @@ void GetApplicationDirs(std::vector<base::FilePath>* locations) { } else { default_location = default_location.Append(L"AppData\\Local"); } - locations->push_back(default_location); + installation_locations.push_back(default_location); } // Add the system-level location. std::string program_dir; if (env->GetVar("ProgramFiles", &program_dir)) - locations->push_back(base::FilePath(UTF8ToWide(program_dir))); + installation_locations.push_back(base::FilePath(UTF8ToWide(program_dir))); if (env->GetVar("ProgramFiles(x86)", &program_dir)) - locations->push_back(base::FilePath(UTF8ToWide(program_dir))); + installation_locations.push_back(base::FilePath(UTF8ToWide(program_dir))); + + for (size_t i = 0; i < installation_locations.size(); ++i) { + locations->push_back( + installation_locations[i].Append(L"Google\\Chrome\\Application")); + } + for (size_t i = 0; i < installation_locations.size(); ++i) { + locations->push_back( + installation_locations[i].Append(L"Chromium\\Application")); + } } #elif defined(OS_LINUX) void GetApplicationDirs(std::vector<base::FilePath>* locations) { @@ -88,8 +98,7 @@ void GetApplicationDirs(std::vector<base::FilePath>* locations); bool FindChrome(base::FilePath* browser_exe) { #if defined(OS_WIN) base::FilePath browser_exes_array[] = { - base::FilePath(L"Google\\Chrome\\Application\\chrome.exe"), - base::FilePath(L"Chromium\\Application\\chrome.exe") + base::FilePath(L"chrome.exe") }; #elif defined(OS_MACOSX) base::FilePath browser_exes_array[] = { @@ -107,6 +116,9 @@ bool FindChrome(base::FilePath* browser_exe) { std::vector<base::FilePath> browser_exes( browser_exes_array, browser_exes_array + arraysize(browser_exes_array)); std::vector<base::FilePath> locations; + base::FilePath module_dir; + if (PathService::Get(base::DIR_MODULE, &module_dir)) + locations.push_back(module_dir); GetApplicationDirs(&locations); return internal::FindExe( base::Bind(&file_util::PathExists), diff --git a/chrome/test/chromedriver/chrome/console_logger_unittest.cc b/chrome/test/chromedriver/chrome/console_logger_unittest.cc index 099f3e433c..8250842e6a 100644 --- a/chrome/test/chromedriver/chrome/console_logger_unittest.cc +++ b/chrome/test/chromedriver/chrome/console_logger_unittest.cc @@ -7,7 +7,7 @@ #include "base/compiler_specific.h" #include "base/format_macros.h" #include "base/memory/scoped_vector.h" -#include "base/time.h" +#include "base/time/time.h" #include "base/values.h" #include "chrome/test/chromedriver/chrome/log.h" #include "chrome/test/chromedriver/chrome/status.h" diff --git a/chrome/test/chromedriver/chrome/device_manager.cc b/chrome/test/chromedriver/chrome/device_manager.cc index 103aa0d4a3..34cfab5a37 100644 --- a/chrome/test/chromedriver/chrome/device_manager.cc +++ b/chrome/test/chromedriver/chrome/device_manager.cc @@ -41,7 +41,9 @@ Device::~Device() { release_callback_.Run(); } -Status Device::StartChrome(const std::string& package, int port) { +Status Device::StartChrome(const std::string& package, + int port, + const std::string& args) { if (!active_package_.empty()) return Status(kUnknownError, active_package_ + " was launched and has not been quit"); @@ -51,7 +53,7 @@ Status Device::StartChrome(const std::string& package, int port) { status = adb_->ClearAppData(serial_, package); if (!status.IsOk()) return status; - status = adb_->SetChromeFlags(serial_); + status = adb_->SetChromeArgs(serial_, args); if (!status.IsOk()) return status; status = adb_->Launch(serial_, package, GetActivityForPackage(package)); diff --git a/chrome/test/chromedriver/chrome/device_manager.h b/chrome/test/chromedriver/chrome/device_manager.h index 5a5844b245..65d70c3006 100644 --- a/chrome/test/chromedriver/chrome/device_manager.h +++ b/chrome/test/chromedriver/chrome/device_manager.h @@ -22,7 +22,9 @@ class Device { public: ~Device(); - Status StartChrome(const std::string& package, int port); + Status StartChrome(const std::string& package, + int port, + const std::string& args); Status StopChrome(); private: diff --git a/chrome/test/chromedriver/chrome/device_manager_unittest.cc b/chrome/test/chromedriver/chrome/device_manager_unittest.cc index 539b695579..7529e63778 100644 --- a/chrome/test/chromedriver/chrome/device_manager_unittest.cc +++ b/chrome/test/chromedriver/chrome/device_manager_unittest.cc @@ -16,8 +16,8 @@ namespace { class FakeAdb : public Adb { public: - FakeAdb() {}; - virtual ~FakeAdb() {}; + FakeAdb() {} + virtual ~FakeAdb() {} virtual Status GetDevices(std::vector<std::string>* devices) OVERRIDE { devices->push_back("a"); @@ -31,7 +31,8 @@ class FakeAdb : public Adb { return Status(kOk); } - virtual Status SetChromeFlags(const std::string& device_serial) OVERRIDE { + virtual Status SetChromeArgs(const std::string& device_serial, + const std::string& args) OVERRIDE { return Status(kOk); } @@ -94,7 +95,7 @@ TEST(Device, LaunchChrome) { scoped_ptr<Device> device1; ASSERT_TRUE(device_manager.AcquireDevice(&device1).IsOk()); ASSERT_FALSE(device1->StopChrome().IsOk()); - ASSERT_TRUE(device1->StartChrome("p", 0).IsOk()); - ASSERT_FALSE(device1->StartChrome("p", 0).IsOk()); + ASSERT_TRUE(device1->StartChrome("p", 0, std::string()).IsOk()); + ASSERT_FALSE(device1->StartChrome("p", 0, std::string()).IsOk()); ASSERT_TRUE(device1->StopChrome().IsOk()); } diff --git a/chrome/test/chromedriver/chrome/devtools_http_client.cc b/chrome/test/chromedriver/chrome/devtools_http_client.cc index 2a4e5883e8..7b5fdb414a 100644 --- a/chrome/test/chromedriver/chrome/devtools_http_client.cc +++ b/chrome/test/chromedriver/chrome/devtools_http_client.cc @@ -9,7 +9,7 @@ #include "base/json/json_reader.h" #include "base/strings/stringprintf.h" #include "base/threading/platform_thread.h" -#include "base/time.h" +#include "base/time/time.h" #include "base/values.h" #include "chrome/test/chromedriver/chrome/devtools_client_impl.h" #include "chrome/test/chromedriver/chrome/log.h" diff --git a/chrome/test/chromedriver/chrome/log.cc b/chrome/test/chromedriver/chrome/log.cc index 7aade7363d..23e7649eb8 100644 --- a/chrome/test/chromedriver/chrome/log.cc +++ b/chrome/test/chromedriver/chrome/log.cc @@ -79,7 +79,7 @@ std::string ConvertForDisplayInternal(const std::string& input) { // Pretty prints encapsulated JSON and truncates long strings for display. std::string ConvertForDisplay(const std::string& input) { std::string display = ConvertForDisplayInternal(input); - char remove_chars[] = {'\r'}; + char remove_chars[] = {'\r', '\0'}; RemoveChars(display, remove_chars, &display); return display; } diff --git a/chrome/test/chromedriver/chrome/log.h b/chrome/test/chromedriver/chrome/log.h index 0a1cf7e6ce..db2eb26587 100644 --- a/chrome/test/chromedriver/chrome/log.h +++ b/chrome/test/chromedriver/chrome/log.h @@ -8,7 +8,7 @@ #include <string> #include "base/compiler_specific.h" -#include "base/time.h" +#include "base/time/time.h" // Abstract class for logging entries with a level, timestamp, string message. class Log { diff --git a/chrome/test/chromedriver/chrome/performance_logger_unittest.cc b/chrome/test/chromedriver/chrome/performance_logger_unittest.cc index a3a36277a8..e6c05b80e5 100644 --- a/chrome/test/chromedriver/chrome/performance_logger_unittest.cc +++ b/chrome/test/chromedriver/chrome/performance_logger_unittest.cc @@ -8,7 +8,7 @@ #include "base/format_macros.h" #include "base/json/json_reader.h" #include "base/memory/scoped_vector.h" -#include "base/time.h" +#include "base/time/time.h" #include "base/values.h" #include "chrome/test/chromedriver/chrome/log.h" #include "chrome/test/chromedriver/chrome/status.h" diff --git a/chrome/test/chromedriver/chrome/web_view_impl.cc b/chrome/test/chromedriver/chrome/web_view_impl.cc index cbff86dfb3..8dce74ef7d 100644 --- a/chrome/test/chromedriver/chrome/web_view_impl.cc +++ b/chrome/test/chromedriver/chrome/web_view_impl.cc @@ -11,7 +11,7 @@ #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/threading/platform_thread.h" -#include "base/time.h" +#include "base/time/time.h" #include "base/values.h" #include "chrome/test/chromedriver/chrome/devtools_client_impl.h" #include "chrome/test/chromedriver/chrome/dom_tracker.h" diff --git a/chrome/test/chromedriver/chrome/zip_reader.h b/chrome/test/chromedriver/chrome/zip_reader.h index a77297231a..451968e2aa 100644 --- a/chrome/test/chromedriver/chrome/zip_reader.h +++ b/chrome/test/chromedriver/chrome/zip_reader.h @@ -11,7 +11,7 @@ #include "base/files/file_path.h" #include "base/memory/scoped_ptr.h" #include "base/platform_file.h" -#include "base/time.h" +#include "base/time/time.h" #if defined(USE_SYSTEM_MINIZIP) #include <minizip/unzip.h> diff --git a/chrome/test/chromedriver/chrome_launcher.cc b/chrome/test/chromedriver/chrome_launcher.cc index b08d1c1b94..f7fb4375ff 100644 --- a/chrome/test/chromedriver/chrome_launcher.cc +++ b/chrome/test/chromedriver/chrome_launcher.cc @@ -8,6 +8,7 @@ #include <vector> #include "base/base64.h" +#include "base/basictypes.h" #include "base/command_line.h" #include "base/file_util.h" #include "base/files/file_path.h" @@ -23,7 +24,7 @@ #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "base/threading/platform_thread.h" -#include "base/time.h" +#include "base/time/time.h" #include "base/values.h" #include "chrome/test/chromedriver/chrome/chrome_android_impl.h" #include "chrome/test/chromedriver/chrome/chrome_desktop_impl.h" @@ -40,6 +41,9 @@ namespace { +const char* kCommonSwitches[] = { + "ignore-certificate-errors", "metrics-recording-only"}; + Status UnpackAutomationExtension(const base::FilePath& temp_dir, base::FilePath* automation_extension) { std::string decoded_extension; @@ -194,9 +198,13 @@ Status LaunchDesktopChrome( CommandLine command(CommandLine::NO_PROGRAM); base::ScopedTempDir user_data_dir; base::ScopedTempDir extension_dir; - PrepareCommandLine(port, capabilities, - &command, &user_data_dir, &extension_dir); - command.AppendSwitch("ignore-certificate-errors"); + Status status = PrepareCommandLine(port, capabilities, + &command, &user_data_dir, &extension_dir); + if (status.IsError()) + return status; + + for (size_t i = 0; i < arraysize(kCommonSwitches); i++) + command.AppendSwitch(kCommonSwitches[i]); base::LaunchOptions options; #if !defined(OS_WIN) @@ -224,7 +232,7 @@ Status LaunchDesktopChrome( scoped_ptr<DevToolsHttpClient> devtools_client; std::string version; int build_no; - Status status = WaitForDevToolsAndCheckVersion( + status = WaitForDevToolsAndCheckVersion( port, context_getter, socket_factory, log, &devtools_client, &version, &build_no); @@ -292,7 +300,13 @@ Status LaunchAndroidChrome( } if (!status.IsOk()) return status; - status = device->StartChrome(capabilities.android_package, port); + + std::string args(capabilities.android_args); + for (size_t i = 0; i < arraysize(kCommonSwitches); i++) + args += "--" + std::string(kCommonSwitches[i]) + " "; + args += "--disable-fre --enable-remote-debugging"; + + status = device->StartChrome(capabilities.android_package, port, args); if (!status.IsOk()) return status; diff --git a/chrome/test/chromedriver/chromedriver.cc b/chrome/test/chromedriver/chromedriver.cc deleted file mode 100644 index 8f7ddce0de..0000000000 --- a/chrome/test/chromedriver/chromedriver.cc +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) 2012 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/chromedriver/chromedriver.h" - -#include "base/json/json_reader.h" -#include "base/json/json_writer.h" -#include "base/lazy_instance.h" -#include "base/memory/scoped_ptr.h" -#include "base/synchronization/lock.h" -#include "base/values.h" -#include "chrome/test/chromedriver/chrome/status.h" -#include "chrome/test/chromedriver/command_executor.h" - -namespace { - -// Guards |g_executor_initialized|. -base::LazyInstance<base::Lock> g_lazy_lock = LAZY_INSTANCE_INITIALIZER; -bool g_executor_initialized = false; -CommandExecutor* g_command_executor = NULL; - -void SetResponse(StatusCode status, - const base::Value* value, - const std::string& session_id, - std::string* response) { - base::DictionaryValue response_dict; - response_dict.SetInteger("status", status); - response_dict.Set("value", value->DeepCopy()); - response_dict.SetString("sessionId", session_id); - std::string json; - base::JSONWriter::Write(&response_dict, response); -} - -void SetError(const std::string& error_msg, - std::string* response) { - base::DictionaryValue value; - value.SetString("message", error_msg); - SetResponse(kUnknownError, &value, std::string(), response); -} - -} // namespace - -void Init(scoped_ptr<CommandExecutor> executor) { - g_command_executor = executor.release(); - // We do not call CommandExecutor::Init here because you can't do some things - // (e.g., creating threads) during DLL loading on Windows. -} - -void ExecuteCommand(const std::string& command, std::string* response) { - CHECK(g_command_executor); - { - base::AutoLock(g_lazy_lock.Get()); - if (!g_executor_initialized) { - g_command_executor->Init(); - g_executor_initialized = true; - } - } - std::string error_msg; - scoped_ptr<base::Value> value(base::JSONReader::ReadAndReturnError( - command, 0, NULL, &error_msg)); - if (!value.get()) { - SetError("failed to parse command: " + error_msg, response); - return; - } - base::DictionaryValue* command_dict; - if (!value->GetAsDictionary(&command_dict)) { - SetError("invalid command (must be dictionary)", response); - return; - } - std::string name; - if (!command_dict->GetString("name", &name)) { - SetError("invalid command (must contain 'name' of type string)", response); - return; - } - base::DictionaryValue* params; - if (!command_dict->GetDictionary("parameters", ¶ms)) { - SetError("invalid command (must contain 'parameters' of type dict)", - response); - return; - } - std::string session_id; - if (!command_dict->GetString("sessionId", &session_id)) { - SetError("invalid command (must contain 'sessionId' of type string)", - response); - return; - } - StatusCode out_status = kOk; - scoped_ptr<base::Value> out_value; - std::string out_session_id; - g_command_executor->ExecuteCommand( - name, *params, session_id, &out_status, &out_value, &out_session_id); - SetResponse(out_status, out_value.get(), out_session_id, response); -} - -void Shutdown() { - // TODO: Move this out to a separate doc. - // On shutdown, it is nice to quit all running sessions so that we don't - // have leftover Chrome processes and temporary user data dirs. - // To do this, we execute the quitAll command. - // Alternative shutdown behaviors: - // 1. If the user doesn't quit the session, don't clean it up. - // This is what the FF driver does, except the temp dir is - // cleaned up in FF because the client side is responsible for creating - // the temp directory, not the driver. - // 2. Separate helper process that we spawn that is in charge of - // launching processes and creating temporary files. This process - // communicates to the helper via a socket. The helper process - // kills all processes and deletes temp files if it sees the parent - // die and then exits itself. This is more complicated, but it guarantees - // that the processes and temp dirs are cleaned up, even if this process - // exits abnormally. - // 3. Add Chrome command-line switch for socket/pipe that Chrome listens - // to and exits if the pipe is closed. This is how the old - // TestingAutomationProvider worked. However, this doesn't clean up - // temp directories, unless we make Chrome clean its own directory too. - // If Chrome crashes the directory would be leaked. - base::DictionaryValue params; - StatusCode status_code; - scoped_ptr<base::Value> value; - std::string session_id; - g_command_executor->ExecuteCommand( - "quitAll", params, std::string(), &status_code, &value, &session_id); - delete g_command_executor; -} diff --git a/chrome/test/chromedriver/chromedriver.h b/chrome/test/chromedriver/chromedriver.h deleted file mode 100644 index 3872b0033e..0000000000 --- a/chrome/test/chromedriver/chromedriver.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2012 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 CHROME_TEST_CHROMEDRIVER_CHROMEDRIVER_H_ -#define CHROME_TEST_CHROMEDRIVER_CHROMEDRIVER_H_ - -#include <string> - -#include "base/memory/scoped_ptr.h" - -class CommandExecutor; - -// Inits the command executor. Must be called before |ExecuteCommand|. -// This may be called during DLL load on Windows. -void Init(scoped_ptr<CommandExecutor> executor); - -// Synchronously executes the given command. Thread safe. -// Command must be a JSON object: -// { -// "name": <string>, -// "parameters": <dictionary>, -// "sessionId": <string> -// } -// Response will always be a JSON object: -// { -// "status": <integer>, -// "value": <object>, -// "sessionId": <string> -// } -// If "status" is non-zero, "value" will be an object with a string "message" -// property which signifies the error message. -void ExecuteCommand(const std::string& command, std::string* response); - -// Shuts down the command executor. No commands must be currently executing. -void Shutdown(); - -#endif // CHROME_TEST_CHROMEDRIVER_CHROMEDRIVER_H_ diff --git a/chrome/test/chromedriver/chromedriver_shared_library.cc b/chrome/test/chromedriver/chromedriver_shared_library.cc deleted file mode 100644 index 9850e2d857..0000000000 --- a/chrome/test/chromedriver/chromedriver_shared_library.cc +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) 2012 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 <cstring> -#include <string> - -#include "base/at_exit.h" -#include "base/memory/scoped_ptr.h" -#include "base/strings/utf_string_conversions.h" -#include "build/build_config.h" -#include "chrome/test/chromedriver/chrome/log.h" -#include "chrome/test/chromedriver/chromedriver.h" -#include "chrome/test/chromedriver/command_executor.h" -#include "chrome/test/chromedriver/command_executor_impl.h" - -#if defined(OS_WIN) -#include <windows.h> -#endif - -#if defined(OS_WIN) -#define EXPORT __declspec(dllexport) -#else -#define EXPORT __attribute__((visibility("default"))) -#endif - -namespace { - -base::AtExitManager* g_at_exit = NULL; -Log* g_log = NULL; - -} // namespace - -extern "C" { - -// Synchronously executes the given command. Thread safe. -// Every call dynamically allocates a |response| string, which must be -// deallocated by calling |Free|. This |response| string is not guaranteed -// to be null terminated, and may contain null characters within. You -// should use the given response size to construct the string. -void EXPORT ExecuteCommand( - const char* command, - unsigned int command_size, - char** response, - unsigned int* response_size) { - std::string command_str(command, command_size); - std::string json; - ExecuteCommand(command_str, &json); - *response = new char[json.length()]; - std::memcpy(*response, json.c_str(), json.length()); - *response_size = json.length(); -} - -void EXPORT Free(char* p) { - delete [] p; -} - -} // extern "C" - -#if defined(OS_WIN) -BOOL APIENTRY DllMain(HMODULE module, DWORD reason, void* reserved) { - if (reason == DLL_PROCESS_ATTACH) { - g_at_exit = new base::AtExitManager(); - g_log = new Logger(); - Init(scoped_ptr<CommandExecutor>(new CommandExecutorImpl(g_log))); - } - if (reason == DLL_PROCESS_DETACH) { - // If |reserved| is not null, the process is terminating and - // ChromeDriver's threads have already been signaled to exit. - // Just leak and let the OS clean it up. - if (reserved) - return TRUE; - Shutdown(); - delete g_log; - delete g_at_exit; - } - return TRUE; -} -#else -void __attribute__((constructor)) OnLoad(void) { - g_at_exit = new base::AtExitManager(); - g_log = new Logger(); - Init(scoped_ptr<CommandExecutor>(new CommandExecutorImpl(g_log))); -} -void __attribute__((destructor)) OnUnload(void) { - Shutdown(); - delete g_log; - delete g_at_exit; -} -#endif diff --git a/chrome/test/chromedriver/chromedriver_unittest.cc b/chrome/test/chromedriver/chromedriver_unittest.cc deleted file mode 100644 index 9e585e328b..0000000000 --- a/chrome/test/chromedriver/chromedriver_unittest.cc +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (c) 2012 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 <list> -#include <string> - -#include "base/bind.h" -#include "base/compiler_specific.h" -#include "base/json/json_reader.h" -#include "base/location.h" -#include "base/memory/scoped_ptr.h" -#include "base/memory/scoped_vector.h" -#include "base/message_loop.h" -#include "base/synchronization/waitable_event.h" -#include "base/threading/thread.h" -#include "base/values.h" -#include "chrome/test/chromedriver/chrome/status.h" -#include "chrome/test/chromedriver/chromedriver.h" -#include "chrome/test/chromedriver/command_executor.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -void ExpectExecuteError(const std::string& command) { - std::string response; - ExecuteCommand(command, &response); - scoped_ptr<base::Value> value(base::JSONReader::Read(response)); - ASSERT_TRUE(value.get()); - base::DictionaryValue* dict; - ASSERT_TRUE(value->GetAsDictionary(&dict)); - int status; - ASSERT_TRUE(dict->GetInteger("status", &status)); - EXPECT_EQ(kUnknownError, status); -} - -class DummyExecutor : public CommandExecutor { - public: - virtual ~DummyExecutor() {} - - virtual void Init() OVERRIDE {} - virtual void ExecuteCommand(const std::string& name, - const base::DictionaryValue& params, - const std::string& session_id, - StatusCode* status, - scoped_ptr<base::Value>* value, - std::string* out_session_id) OVERRIDE {} -}; - - -struct ExpectedCommand { - ExpectedCommand( - const std::string& name, - const base::DictionaryValue& in_params, - const std::string& session_id, - StatusCode return_status, - scoped_ptr<base::Value> return_value, - const std::string& return_session_id) - : name(name), - session_id(session_id), - return_status(return_status), - return_value(return_value.Pass()), - return_session_id(return_session_id) { - params.MergeDictionary(&in_params); - } - - ~ExpectedCommand() {} - - std::string name; - base::DictionaryValue params; - std::string session_id; - StatusCode return_status; - scoped_ptr<base::Value> return_value; - std::string return_session_id; -}; - -class ExecutorMock : public CommandExecutor { - public: - virtual ~ExecutorMock() { - EXPECT_TRUE(DidSatisfyExpectations()); - } - - virtual void Init() OVERRIDE {} - - virtual void ExecuteCommand(const std::string& name, - const base::DictionaryValue& params, - const std::string& session_id, - StatusCode* status, - scoped_ptr<base::Value>* value, - std::string* out_session_id) OVERRIDE { - ASSERT_TRUE(expectations_.size()); - ASSERT_STREQ(expectations_[0]->name.c_str(), name.c_str()); - ASSERT_TRUE(expectations_[0]->params.Equals(¶ms)); - ASSERT_STREQ(expectations_[0]->session_id.c_str(), session_id.c_str()); - *status = expectations_[0]->return_status; - value->reset(expectations_[0]->return_value.release()); - *out_session_id = expectations_[0]->return_session_id; - expectations_.erase(expectations_.begin()); - } - - void Expect(scoped_ptr<ExpectedCommand> expected) { - expectations_.push_back(expected.release()); - } - - bool DidSatisfyExpectations() const { - return expectations_.empty(); - } - - private: - ScopedVector<ExpectedCommand> expectations_; -}; - -} // namespace - -TEST(ChromeDriver, InvalidCommands) { - Init(scoped_ptr<CommandExecutor>(new DummyExecutor())); - ExpectExecuteError("hi[]"); - ExpectExecuteError("[]"); - ExpectExecuteError( - "{\"parameters\": {}, \"sessionId\": \"\"}"); - ExpectExecuteError( - "{\"name\": 1, \"parameters\": {}, \"sessionId\": \"\"}"); - ExpectExecuteError( - "{\"name\": \"\", \"sessionId\": \"\"}"); - ExpectExecuteError( - "{\"name\": \"\", \"parameters\": 1, \"sessionId\": \"\"}"); - ExpectExecuteError( - "{\"name\": \"\", \"parameters\": {}}"); - ExpectExecuteError( - "{\"name\": \"\", \"parameters\": {}, \"sessionId\": 1}"); - Shutdown(); -} - -TEST(ChromeDriver, ExecuteCommand) { - scoped_ptr<ExecutorMock> scoped_mock(new ExecutorMock()); - ExecutorMock* mock = scoped_mock.get(); - Init(scoped_mock.PassAs<CommandExecutor>()); - { - base::DictionaryValue params; - params.SetInteger("param", 100); - scoped_ptr<base::Value> value(new base::StringValue("stuff")); - mock->Expect(scoped_ptr<ExpectedCommand>(new ExpectedCommand( - "name", params, "id", kOk, value.Pass(), "session_id"))); - } - std::string response; - ExecuteCommand("{\"name\": \"name\", " - " \"parameters\": {\"param\": 100}, " - " \"sessionId\": \"id\"}", - &response); - ASSERT_TRUE(mock->DidSatisfyExpectations()); - { - scoped_ptr<base::Value> value(base::JSONReader::Read(response)); - ASSERT_TRUE(value.get()); - base::DictionaryValue* dict; - ASSERT_TRUE(value->GetAsDictionary(&dict)); - int status; - ASSERT_TRUE(dict->GetInteger("status", &status)); - std::string value_str; - ASSERT_TRUE(dict->GetString("value", &value_str)); - EXPECT_STREQ("stuff", value_str.c_str()); - EXPECT_EQ(kOk, status); - } - { - base::DictionaryValue params; - scoped_ptr<base::Value> value(base::Value::CreateNullValue()); - mock->Expect(scoped_ptr<ExpectedCommand>(new ExpectedCommand( - "quitAll", params, std::string(), kOk, value.Pass(), std::string()))); - } - Shutdown(); -} diff --git a/chrome/test/chromedriver/command_executor.h b/chrome/test/chromedriver/command_executor.h deleted file mode 100644 index e5d60c6cc2..0000000000 --- a/chrome/test/chromedriver/command_executor.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2012 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 CHROME_TEST_CHROMEDRIVER_COMMAND_EXECUTOR_H_ -#define CHROME_TEST_CHROMEDRIVER_COMMAND_EXECUTOR_H_ - -#include <string> - -#include "base/basictypes.h" -#include "base/memory/scoped_ptr.h" -#include "base/threading/non_thread_safe.h" -#include "chrome/test/chromedriver/chrome/status.h" - -namespace base { -class DictionaryValue; -class Value; -} - -// Executes WebDriver commands. -class CommandExecutor { - public: - virtual ~CommandExecutor() {} - - virtual void Init() = 0; - - // Executes a command synchronously. This function must be thread safe. - virtual void ExecuteCommand(const std::string& name, - const base::DictionaryValue& params, - const std::string& session_id, - StatusCode* status_code, - scoped_ptr<base::Value>* value, - std::string* out_session_id) = 0; -}; - -#endif // CHROME_TEST_CHROMEDRIVER_COMMAND_EXECUTOR_H_ diff --git a/chrome/test/chromedriver/command_executor_impl.h b/chrome/test/chromedriver/command_executor_impl.h deleted file mode 100644 index fa8312bf19..0000000000 --- a/chrome/test/chromedriver/command_executor_impl.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2012 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 CHROME_TEST_CHROMEDRIVER_COMMAND_EXECUTOR_IMPL_H_ -#define CHROME_TEST_CHROMEDRIVER_COMMAND_EXECUTOR_IMPL_H_ - -#include <string> - -#include "base/basictypes.h" -#include "base/callback_forward.h" -#include "base/compiler_specific.h" -#include "base/gtest_prod_util.h" -#include "base/memory/scoped_ptr.h" -#include "base/threading/thread.h" -#include "chrome/test/chromedriver/chrome/status.h" -#include "chrome/test/chromedriver/command.h" -#include "chrome/test/chromedriver/command_executor.h" -#include "chrome/test/chromedriver/net/sync_websocket_factory.h" -#include "chrome/test/chromedriver/session_map.h" -#include "chrome/test/chromedriver/synchronized_map.h" - -namespace base { -class DictionaryValue; -class Value; -} - -class Adb; -class ChromeLauncherImpl; -class DeviceManager; -class Log; -class URLRequestContextGetter; - -class CommandExecutorImpl : public CommandExecutor { - public: - explicit CommandExecutorImpl(Log* log); - virtual ~CommandExecutorImpl(); - - // Overridden from CommandExecutor: - virtual void Init() OVERRIDE; - virtual void ExecuteCommand(const std::string& name, - const base::DictionaryValue& params, - const std::string& session_id, - StatusCode* status_code, - scoped_ptr<base::Value>* value, - std::string* out_session_id) OVERRIDE; - - private: - FRIEND_TEST_ALL_PREFIXES(CommandExecutorImplTest, SimpleCommand); - FRIEND_TEST_ALL_PREFIXES( - CommandExecutorImplTest, CommandThatDoesntSetValueOrSessionId); - FRIEND_TEST_ALL_PREFIXES(CommandExecutorImplTest, CommandThatReturnsError); - - Log* log_; - base::Thread io_thread_; - scoped_refptr<URLRequestContextGetter> context_getter_; - SyncWebSocketFactory socket_factory_; - SessionMap session_map_; - SynchronizedMap<std::string, Command> command_map_; - scoped_ptr<Adb> adb_; - scoped_ptr<DeviceManager> device_manager_; - - DISALLOW_COPY_AND_ASSIGN(CommandExecutorImpl); -}; - -#endif // CHROME_TEST_CHROMEDRIVER_COMMAND_EXECUTOR_IMPL_H_ diff --git a/chrome/test/chromedriver/command_names.cc b/chrome/test/chromedriver/command_names.cc deleted file mode 100644 index e90add67dd..0000000000 --- a/chrome/test/chromedriver/command_names.cc +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) 2013 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/chromedriver/command_names.h" - -const char CommandNames::kNewSession[] = "newSession"; -const char CommandNames::kStatus[] = "status"; -const char CommandNames::kClose[] = "close"; -const char CommandNames::kQuit[] = "quit"; -const char CommandNames::kGet[] = "get"; -const char CommandNames::kGoBack[] = "goBack"; -const char CommandNames::kGoForward[] = "goForward"; -const char CommandNames::kRefresh[] = "refresh"; -const char CommandNames::kAddCookie[] = "addCookie"; -const char CommandNames::kGetCookie[] = "getCookie"; -const char CommandNames::kGetCookies[] = "getCookies"; -const char CommandNames::kDeleteCookie[] = "deleteCookie"; -const char CommandNames::kDeleteAllCookies[] = "deleteAllCookies"; -const char CommandNames::kFindElement[] = "findElement"; -const char CommandNames::kFindElements[] = "findElements"; -const char CommandNames::kFindChildElement[] = "findChildElement"; -const char CommandNames::kFindChildElements[] = "findChildElements"; -const char CommandNames::kClearElement[] = "clearElement"; -const char CommandNames::kClickElement[] = "clickElement"; -const char CommandNames::kHoverOverElement[] = "hoverOverElement"; -const char CommandNames::kSendKeysToElement[] = "sendKeysToElement"; -const char CommandNames::kSendKeysToActiveElement[] = "sendKeysToActiveElement"; -const char CommandNames::kSubmitElement[] = "submitElement"; -const char CommandNames::kUploadFile[] = "uploadFile"; -const char CommandNames::kGetCurrentWindowHandle[] = "getCurrentWindowHandle"; -const char CommandNames::kGetWindowHandles[] = "getWindowHandles"; -const char CommandNames::kSwitchToWindow[] = "switchToWindow"; -const char CommandNames::kSwitchToFrame[] = "switchToFrame"; -const char CommandNames::kGetActiveElement[] = "getActiveElement"; -const char CommandNames::kGetCurrentUrl[] = "getCurrentUrl"; -const char CommandNames::kGetPageSource[] = "getPageSource"; -const char CommandNames::kGetTitle[] = "getTitle"; -const char CommandNames::kExecuteScript[] = "executeScript"; -const char CommandNames::kExecuteAsyncScript[] = "executeAsyncScript"; -const char CommandNames::kSetBrowserVisible[] = "setBrowserVisible"; -const char CommandNames::kIsBrowserVisible[] = "isBrowserVisible"; -const char CommandNames::kGetElementText[] = "getElementText"; -const char CommandNames::kGetElementValue[] = "getElementValue"; -const char CommandNames::kGetElementTagName[] = "getElementTagName"; -const char CommandNames::kDragElement[] = "dragElement"; -const char CommandNames::kIsElementSelected[] = "isElementSelected"; -const char CommandNames::kIsElementEnabled[] = "isElementEnabled"; -const char CommandNames::kIsElementDisplayed[] = "isElementDisplayed"; -const char CommandNames::kGetElementLocation[] = "getElementLocation"; -const char CommandNames::kGetElementLocationOnceScrolledIntoView[] = - "getElementLocationOnceScrolledIntoView"; -const char CommandNames::kGetElementSize[] = "getElementSize"; -const char CommandNames::kGetElementAttribute[] = "getElementAttribute"; -const char CommandNames::kGetElementValueOfCssProperty[] = - "getElementValueOfCssProperty"; -const char CommandNames::kElementEquals[] = "elementEquals"; -const char CommandNames::kScreenshot[] = "screenshot"; -const char CommandNames::kGetAlert[] = "getAlert"; -const char CommandNames::kAcceptAlert[] = "acceptAlert"; -const char CommandNames::kDismissAlert[] = "dismissAlert"; -const char CommandNames::kGetAlertText[] = "getAlertText"; -const char CommandNames::kSetAlertValue[] = "setAlertValue"; -const char CommandNames::kSetTimeout[] = "setTimeout"; -const char CommandNames::kImplicitlyWait[] = "implicitlyWait"; -const char CommandNames::kSetScriptTimeout[] = "setScriptTimeout"; -const char CommandNames::kExecuteSQL[] = "executeSQL"; -const char CommandNames::kGetLocation[] = "getLocation"; -const char CommandNames::kSetLocation[] = "setLocation"; -const char CommandNames::kGetAppCache[] = "getAppCache"; -const char CommandNames::kGetStatus[] = "getStatus"; -const char CommandNames::kClearAppCache[] = "clearAppCache"; -const char CommandNames::kIsBrowserOnline[] = "isBrowserOnline"; -const char CommandNames::kSetBrowserOnline[] = "setBrowserOnline"; -const char CommandNames::kGetLocalStorageItem[] = "getLocalStorageItem"; -const char CommandNames::kGetLocalStorageKeys[] = "getLocalStorageKeys"; -const char CommandNames::kSetLocalStorageItem[] = "setLocalStorageItem"; -const char CommandNames::kRemoveLocalStorageItem[] = "removeLocalStorageItem"; -const char CommandNames::kClearLocalStorage[] = "clearLocalStorage"; -const char CommandNames::kGetLocalStorageSize[] = "getLocalStorageSize"; -const char CommandNames::kGetSessionStorageItem[] = "getSessionStorageItem"; -const char CommandNames::kGetSessionStorageKey[] = "getSessionStorageKey"; -const char CommandNames::kSetSessionStorageItem[] = "setSessionStorageItem"; -const char CommandNames::kRemoveSessionStorageItem[] = - "removeSessionStorageItem"; -const char CommandNames::kClearSessionStorage[] = "clearSessionStorage"; -const char CommandNames::kGetSessionStorageSize[] = "getSessionStorageSize"; -const char CommandNames::kSetScreenOrientation[] = "setScreenOrientation"; -const char CommandNames::kGetScreenOrientation[] = "getScreenOrientation"; -const char CommandNames::kMouseClick[] = "mouseClick"; -const char CommandNames::kMouseDoubleClick[] = "mouseDoubleClick"; -const char CommandNames::kMouseButtonDown[] = "mouseButtonDown"; -const char CommandNames::kMouseButtonUp[] = "mouseButtonUp"; -const char CommandNames::kMouseMoveTo[] = "mouseMoveTo"; -const char CommandNames::kSendKeys[] = "sendKeys"; -const char CommandNames::kImeGetAvailableEngines[] = "imeGetAvailableEngines"; -const char CommandNames::kImeGetActiveEngine[] = "imeGetActiveEngine"; -const char CommandNames::kImeIsActivated[] = "imeIsActivated"; -const char CommandNames::kImeDeactivate[] = "imeDeactivate"; -const char CommandNames::kImeActivateEngine[] = "imeActivateEngine"; -const char CommandNames::kTouchSingleTap[] = "touchSingleTap"; -const char CommandNames::kTouchDown[] = "touchDown"; -const char CommandNames::kTouchUp[] = "touchUp"; -const char CommandNames::kTouchMove[] = "touchMove"; -const char CommandNames::kTouchScroll[] = "touchScroll"; -const char CommandNames::kTouchDoubleTap[] = "touchDoubleTap"; -const char CommandNames::kTouchLongPress[] = "touchLongPress"; -const char CommandNames::kTouchFlick[] = "touchFlick"; -const char CommandNames::kSetWindowSize[] = "setWindowSize"; -const char CommandNames::kSetWindowPosition[] = "setWindowPosition"; -const char CommandNames::kGetWindowSize[] = "getWindowSize"; -const char CommandNames::kGetWindowPosition[] = "getWindowPosition"; -const char CommandNames::kMaximizeWindow[] = "maximizeWindow"; -const char CommandNames::kGetAvailableLogTypes[] = "getAvailableLogTypes"; -const char CommandNames::kGetLog[] = "getLog"; -const char CommandNames::kGetSessionLogs[] = "getSessionLogs"; - -// Custom Chrome commands: -const char CommandNames::kQuitAll[] = "quitAll"; -const char CommandNames::kGetSessionCapabilities[] = "getSessionCapabilities"; -const char CommandNames::kIsLoading[] = "isLoading"; diff --git a/chrome/test/chromedriver/command_names.h b/chrome/test/chromedriver/command_names.h deleted file mode 100644 index 4626463110..0000000000 --- a/chrome/test/chromedriver/command_names.h +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (c) 2013 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 CHROME_TEST_CHROMEDRIVER_COMMAND_NAMES_H_ -#define CHROME_TEST_CHROMEDRIVER_COMMAND_NAMES_H_ - -class CommandNames { - public: - static const char kNewSession[]; - static const char kStatus[]; - static const char kClose[]; - static const char kQuit[]; - static const char kGet[]; - static const char kGoBack[]; - static const char kGoForward[]; - static const char kRefresh[]; - static const char kAddCookie[]; - static const char kGetCookie[]; - static const char kGetCookies[]; - static const char kDeleteCookie[]; - static const char kDeleteAllCookies[]; - static const char kFindElement[]; - static const char kFindElements[]; - static const char kFindChildElement[]; - static const char kFindChildElements[]; - static const char kClearElement[]; - static const char kClickElement[]; - static const char kHoverOverElement[]; - static const char kSendKeysToElement[]; - static const char kSendKeysToActiveElement[]; - static const char kSubmitElement[]; - static const char kUploadFile[]; - static const char kGetCurrentWindowHandle[]; - static const char kGetWindowHandles[]; - static const char kSwitchToWindow[]; - static const char kSwitchToFrame[]; - static const char kGetActiveElement[]; - static const char kGetCurrentUrl[]; - static const char kGetPageSource[]; - static const char kGetTitle[]; - static const char kExecuteScript[]; - static const char kExecuteAsyncScript[]; - static const char kSetBrowserVisible[]; - static const char kIsBrowserVisible[]; - static const char kGetElementText[]; - static const char kGetElementValue[]; - static const char kGetElementTagName[]; - static const char kDragElement[]; - static const char kIsElementSelected[]; - static const char kIsElementEnabled[]; - static const char kIsElementDisplayed[]; - static const char kGetElementLocation[]; - static const char kGetElementLocationOnceScrolledIntoView[]; - static const char kGetElementSize[]; - static const char kGetElementAttribute[]; - static const char kGetElementValueOfCssProperty[]; - static const char kElementEquals[]; - static const char kScreenshot[]; - static const char kGetAlert[]; - static const char kAcceptAlert[]; - static const char kDismissAlert[]; - static const char kGetAlertText[]; - static const char kSetAlertValue[]; - static const char kSetTimeout[]; - static const char kImplicitlyWait[]; - static const char kSetScriptTimeout[]; - static const char kExecuteSQL[]; - static const char kGetLocation[]; - static const char kSetLocation[]; - static const char kGetAppCache[]; - static const char kGetStatus[]; - static const char kClearAppCache[]; - static const char kIsBrowserOnline[]; - static const char kSetBrowserOnline[]; - static const char kGetLocalStorageItem[]; - static const char kGetLocalStorageKeys[]; - static const char kSetLocalStorageItem[]; - static const char kRemoveLocalStorageItem[]; - static const char kClearLocalStorage[]; - static const char kGetLocalStorageSize[]; - static const char kGetSessionStorageItem[]; - static const char kGetSessionStorageKey[]; - static const char kSetSessionStorageItem[]; - static const char kRemoveSessionStorageItem[]; - static const char kClearSessionStorage[]; - static const char kGetSessionStorageSize[]; - static const char kSetScreenOrientation[]; - static const char kGetScreenOrientation[]; - static const char kMouseClick[]; - static const char kMouseDoubleClick[]; - static const char kMouseButtonDown[]; - static const char kMouseButtonUp[]; - static const char kMouseMoveTo[]; - static const char kSendKeys[]; - static const char kImeGetAvailableEngines[]; - static const char kImeGetActiveEngine[]; - static const char kImeIsActivated[]; - static const char kImeDeactivate[]; - static const char kImeActivateEngine[]; - static const char kTouchSingleTap[]; - static const char kTouchDown[]; - static const char kTouchUp[]; - static const char kTouchMove[]; - static const char kTouchScroll[]; - static const char kTouchDoubleTap[]; - static const char kTouchLongPress[]; - static const char kTouchFlick[]; - static const char kSetWindowSize[]; - static const char kSetWindowPosition[]; - static const char kGetWindowSize[]; - static const char kGetWindowPosition[]; - static const char kMaximizeWindow[]; - static const char kGetAvailableLogTypes[]; - static const char kGetLog[]; - static const char kGetSessionLogs[]; - - // Custom Chrome commands: - static const char kQuitAll[]; - static const char kGetSessionCapabilities[]; - static const char kIsLoading[]; -}; - -#endif // CHROME_TEST_CHROMEDRIVER_COMMAND_NAMES_H_ diff --git a/chrome/test/chromedriver/commands_unittest.cc b/chrome/test/chromedriver/commands_unittest.cc index 977fb8be6a..5e7ea33b1f 100644 --- a/chrome/test/chromedriver/commands_unittest.cc +++ b/chrome/test/chromedriver/commands_unittest.cc @@ -15,7 +15,6 @@ #include "chrome/test/chromedriver/chrome/stub_chrome.h" #include "chrome/test/chromedriver/chrome/stub_web_view.h" #include "chrome/test/chromedriver/chrome/web_view.h" -#include "chrome/test/chromedriver/command_executor_impl.h" #include "chrome/test/chromedriver/commands.h" #include "chrome/test/chromedriver/element_commands.h" #include "chrome/test/chromedriver/fake_session_accessor.h" diff --git a/chrome/test/chromedriver/element_commands.cc b/chrome/test/chromedriver/element_commands.cc index 51479862e9..262cfdc1b8 100644 --- a/chrome/test/chromedriver/element_commands.cc +++ b/chrome/test/chromedriver/element_commands.cc @@ -12,7 +12,7 @@ #include "base/strings/string_split.h" #include "base/strings/stringprintf.h" #include "base/threading/platform_thread.h" -#include "base/time.h" +#include "base/time/time.h" #include "base/values.h" #include "chrome/test/chromedriver/basic_types.h" #include "chrome/test/chromedriver/chrome/chrome.h" diff --git a/chrome/test/chromedriver/element_util.cc b/chrome/test/chromedriver/element_util.cc index 734fd09cf3..ccf5409db3 100644 --- a/chrome/test/chromedriver/element_util.cc +++ b/chrome/test/chromedriver/element_util.cc @@ -8,7 +8,7 @@ #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/threading/platform_thread.h" -#include "base/time.h" +#include "base/time/time.h" #include "base/values.h" #include "chrome/test/chromedriver/basic_types.h" #include "chrome/test/chromedriver/chrome/js.h" @@ -127,7 +127,7 @@ Status ScrollElementRegionIntoViewHelper( const std::string& element_id, const WebRect& region, bool center, - bool verify_clickable, + const std::string& clickable_element_id, WebPoint* location) { WebPoint tmp_location = *location; base::ListValue args; @@ -144,10 +144,11 @@ Status ScrollElementRegionIntoViewHelper( return Status(kUnknownError, "failed to parse value of GET_LOCATION_IN_VIEW"); } - if (verify_clickable) { + if (!clickable_element_id.empty()) { WebPoint middle = tmp_location; middle.Offset(region.Width() / 2, region.Height() / 2); - status = VerifyElementClickable(frame, web_view, element_id, middle); + status = VerifyElementClickable( + frame, web_view, clickable_element_id, middle); if (status.IsError()) return status; } @@ -324,9 +325,44 @@ Status GetElementClickableLocation( WebView* web_view, const std::string& element_id, WebPoint* location) { + std::string tag_name; + Status status = GetElementTagName(session, web_view, element_id, &tag_name); + if (status.IsError()) + return status; + std::string target_element_id = element_id; + if (tag_name == "area") { + // Scroll the image into view instead of the area. + const char* kGetImageElementForArea = + "function (element) {" + " var map = element.parentElement;" + " if (map.tagName.toLowerCase() != 'map')" + " throw new Error('the area is not within a map');" + " var mapName = map.getAttribute('name');" + " if (mapName == null)" + " throw new Error ('area\\'s parent map must have a name');" + " mapName = '#' + mapName.toLowerCase();" + " var images = document.getElementsByTagName('img');" + " for (var i = 0; i < images.length; i++) {" + " if (images[i].useMap.toLowerCase() == mapName)" + " return images[i];" + " }" + " throw new Error('no img is found for the area');" + "}"; + base::ListValue args; + args.Append(CreateElement(element_id)); + scoped_ptr<base::Value> result; + status = web_view->CallFunction( + session->GetCurrentFrameId(), kGetImageElementForArea, args, &result); + if (status.IsError()) + return status; + const base::DictionaryValue* element_dict; + if (!result->GetAsDictionary(&element_dict) || + !element_dict->GetString(kElementKey, &target_element_id)) + return Status(kUnknownError, "no element reference returned by script"); + } bool is_displayed = false; - Status status = IsElementDisplayed( - session, web_view, element_id, true, &is_displayed); + status = IsElementDisplayed( + session, web_view, target_element_id, true, &is_displayed); if (status.IsError()) return status; if (!is_displayed) @@ -338,8 +374,8 @@ Status GetElementClickableLocation( return status; status = ScrollElementRegionIntoView( - session, web_view, element_id, rect, - true /* center */, true /* verify_clickable */, location); + session, web_view, target_element_id, rect, + true /* center */, element_id, location); if (status.IsError()) return status; location->Offset(rect.Width() / 2, rect.Height() / 2); @@ -524,7 +560,7 @@ Status ScrollElementIntoView( return status; return ScrollElementRegionIntoView( session, web_view, id, WebRect(WebPoint(0, 0), size), - false /* center */, false /* verify_clickable */, location); + false /* center */, std::string(), location); } Status ScrollElementRegionIntoView( @@ -533,13 +569,13 @@ Status ScrollElementRegionIntoView( const std::string& element_id, const WebRect& region, bool center, - bool verify_clickable, + const std::string& clickable_element_id, WebPoint* location) { WebPoint region_offset = region.origin; WebSize region_size = region.size; Status status = ScrollElementRegionIntoViewHelper( session->GetCurrentFrameId(), web_view, element_id, region, - center, verify_clickable, ®ion_offset); + center, clickable_element_id, ®ion_offset); if (status.IsError()) return status; const char* kFindSubFrameScript = @@ -578,7 +614,7 @@ Status ScrollElementRegionIntoView( status = ScrollElementRegionIntoViewHelper( rit->parent_frame_id, web_view, frame_element_id, WebRect(region_offset, region_size), - center, verify_clickable, ®ion_offset); + center, frame_element_id, ®ion_offset); if (status.IsError()) return status; } diff --git a/chrome/test/chromedriver/element_util.h b/chrome/test/chromedriver/element_util.h index 5c543642b3..86bb2d1568 100644 --- a/chrome/test/chromedriver/element_util.h +++ b/chrome/test/chromedriver/element_util.h @@ -119,16 +119,21 @@ Status ToggleOptionElement( Status ScrollElementIntoView( Session* session, WebView* web_view, - const std::string& id, + const std::string& element_id, WebPoint* location); +// |element_id| refers to the element which is to be scrolled into view. +// |clickable_element_id| refers to the element needing clickable verification. +// They are usually the same, but can be different. This is useful when an image +// uses map/area. The image is scrolled, but check clickable against the area. +// If |clickable_element_id| is "", no verification will be performed. Status ScrollElementRegionIntoView( Session* session, WebView* web_view, const std::string& element_id, const WebRect& region, bool center, - bool verify_clickable, + const std::string& clickable_element_id, WebPoint* location); #endif // CHROME_TEST_CHROMEDRIVER_ELEMENT_UTIL_H_ diff --git a/chrome/test/chromedriver/js/get_element_region.js b/chrome/test/chromedriver/js/get_element_region.js index f83b35b307..19cf11c8a8 100644 --- a/chrome/test/chromedriver/js/get_element_region.js +++ b/chrome/test/chromedriver/js/get_element_region.js @@ -13,6 +13,58 @@ function getElementRegion(element) { var clientRects = element.getClientRects(); if (clientRects.length == 0) { var box = element.getBoundingClientRect(); + if (element.tagName.toLowerCase() == 'area') { + var coords = element.coords.split(','); + if (element.shape.toLowerCase() == 'rect') { + if (coords.length != 4) + throw new Error('failed to detect the region of the area'); + var leftX = Number(coords[0]); + var topY = Number(coords[1]); + var rightX = Number(coords[2]); + var bottomY = Number(coords[3]); + return { + 'left': leftX, + 'top': topY, + 'width': rightX - leftX, + 'height': bottomY - topY + }; + } else if (element.shape.toLowerCase() == 'circle') { + if (coords.length != 3) + throw new Error('failed to detect the region of the area'); + var centerX = Number(coords[0]); + var centerY = Number(coords[1]); + var radius = Number(coords[2]); + return { + 'left': Math.max(0, centerX - radius), + 'top': Math.max(0, centerY - radius), + 'width': radius * 2, + 'height': radius * 2 + }; + } else if (element.shape.toLowerCase() == 'poly') { + if (coords.length < 2) + throw new Error('failed to detect the region of the area'); + var minX = Number(coords[0]); + var minY = Number(coords[1]); + var maxX = minX; + var maxY = minY; + for (i = 2; i < coords.length; i += 2) { + var x = Number(coords[i]); + var y = Number(coords[i + 1]); + minX = Math.min(minX, x); + minY = Math.min(minY, y); + maxX = Math.max(maxX, x); + maxY = Math.max(maxY, y); + } + return { + 'left': minX, + 'top': minY, + 'width': maxX - minX, + 'height': maxY - minY + }; + } else { + throw new Error('shape=' + element.shape + ' is not supported'); + } + } return { 'left': 0, 'top': 0, diff --git a/chrome/test/chromedriver/js/get_element_region_test.html b/chrome/test/chromedriver/js/get_element_region_test.html index e17ea2ccd2..9dd42e0f64 100644 --- a/chrome/test/chromedriver/js/get_element_region_test.html +++ b/chrome/test/chromedriver/js/get_element_region_test.html @@ -37,6 +37,38 @@ function testElementWithoutBoundingRectangle() { assertEquals(0, region.height); } +function testAreaPoly() { + var region = getElementRegion(document.getElementById('poly')); + assertEquals(20, region.left); + assertEquals(10, region.top); + assertEquals(40, region.width); + assertEquals(45, region.height); +} + +function testAreaRect() { + var region = getElementRegion(document.getElementById('rect')); + assertEquals(120, region.left); + assertEquals(100, region.top); + assertEquals(20, region.width); + assertEquals(50, region.height); +} + +function testAreaCircle() { + var region = getElementRegion(document.getElementById('circle')); + assertEquals(175, region.left); + assertEquals(165, region.top); + assertEquals(10, region.width); + assertEquals(10, region.height); +} + +function testAreaDefault() { + try { + getElementRegion(document.getElementById('default')); + assert(false); + } catch (error) { + } +} + </script> <body> <div style="border: 3px coral solid;"> @@ -49,6 +81,16 @@ function testElementWithoutBoundingRectangle() { </ellipse> </svg> </div> + <br> + <div> + <img width="200" height="200" usemap="#imgmap"> + <map name="imgmap"> + <area id="poly" shape="poly" coords="20,20,30,10,50,20,60,40,50,50,30,55"> + <area id="rect" shape="rect" coords="120,100,140,150"> + <area id="circle" shape="circle" coords="180,170,5"> + <area id="default" shape="default"> + </map> + </div> </div> </body> </html> diff --git a/chrome/test/chromedriver/keycode_text_conversion_mac.mm b/chrome/test/chromedriver/keycode_text_conversion_mac.mm index 4b02ace2be..d83df65729 100644 --- a/chrome/test/chromedriver/keycode_text_conversion_mac.mm +++ b/chrome/test/chromedriver/keycode_text_conversion_mac.mm @@ -44,7 +44,7 @@ bool ConvertKeyCodeToText( // on UCKeyTranslate for more info. UInt32 modifier_key_state = (mac_modifiers >> 8) & 0xFF; - base::mac::ScopedCFTypeRef<TISInputSourceRef> input_source_copy( + base::ScopedCFTypeRef<TISInputSourceRef> input_source_copy( TISCopyCurrentKeyboardLayoutInputSource()); CFDataRef layout_data = static_cast<CFDataRef>(TISGetInputSourceProperty( input_source_copy, kTISPropertyUnicodeKeyLayoutData)); diff --git a/chrome/test/chromedriver/logging.cc b/chrome/test/chromedriver/logging.cc index 607cbfe725..bf0a50a69a 100644 --- a/chrome/test/chromedriver/logging.cc +++ b/chrome/test/chromedriver/logging.cc @@ -6,7 +6,7 @@ #include "base/basictypes.h" #include "base/logging.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/test/chromedriver/capabilities.h" #include "chrome/test/chromedriver/chrome/console_logger.h" #include "chrome/test/chromedriver/chrome/performance_logger.h" diff --git a/chrome/test/chromedriver/net/sync_websocket.h b/chrome/test/chromedriver/net/sync_websocket.h index 6835c69c00..5dd59da544 100644 --- a/chrome/test/chromedriver/net/sync_websocket.h +++ b/chrome/test/chromedriver/net/sync_websocket.h @@ -7,7 +7,7 @@ #include <string> -#include "base/time.h" +#include "base/time/time.h" class GURL; diff --git a/chrome/test/chromedriver/net/sync_websocket_impl_unittest.cc b/chrome/test/chromedriver/net/sync_websocket_impl_unittest.cc index e9daca6948..218c597dd3 100644 --- a/chrome/test/chromedriver/net/sync_websocket_impl_unittest.cc +++ b/chrome/test/chromedriver/net/sync_websocket_impl_unittest.cc @@ -11,7 +11,7 @@ #include "base/single_thread_task_runner.h" #include "base/threading/platform_thread.h" #include "base/threading/thread.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/test/chromedriver/net/sync_websocket_impl.h" #include "chrome/test/chromedriver/net/test_http_server.h" #include "chrome/test/chromedriver/net/url_request_context_getter.h" diff --git a/chrome/test/chromedriver/net/test_http_server.cc b/chrome/test/chromedriver/net/test_http_server.cc index 486e1b941c..f776844d02 100644 --- a/chrome/test/chromedriver/net/test_http_server.cc +++ b/chrome/test/chromedriver/net/test_http_server.cc @@ -9,7 +9,7 @@ #include "base/message_loop.h" #include "base/message_loop/message_loop_proxy.h" #include "base/strings/stringprintf.h" -#include "base/time.h" +#include "base/time/time.h" #include "net/base/ip_endpoint.h" #include "net/base/net_errors.h" #include "net/server/http_server_request_info.h" diff --git a/chrome/test/chromedriver/net/websocket_unittest.cc b/chrome/test/chromedriver/net/websocket_unittest.cc index f665c84b29..3176430e82 100644 --- a/chrome/test/chromedriver/net/websocket_unittest.cc +++ b/chrome/test/chromedriver/net/websocket_unittest.cc @@ -15,7 +15,7 @@ #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/threading/thread.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/test/chromedriver/net/test_http_server.h" #include "chrome/test/chromedriver/net/websocket.h" #include "googleurl/src/gurl.h" diff --git a/chrome/test/chromedriver/run_all_tests.py b/chrome/test/chromedriver/run_all_tests.py index 30eadd5771..574fa92def 100755 --- a/chrome/test/chromedriver/run_all_tests.py +++ b/chrome/test/chromedriver/run_all_tests.py @@ -104,6 +104,11 @@ def RunCppTests(cpp_tests): return code +def DownloadChrome(version_name, revision, download_site): + util.MarkBuildStepStart('download %s' % version_name) + return archive.DownloadChrome(revision, util.MakeTempDir(), download_site) + + def main(): parser = optparse.OptionParser() parser.add_option( @@ -159,6 +164,7 @@ def main(): latest_snapshot_revision = archive.GetLatestRevision(archive.Site.SNAPSHOT) versions = [ ['HEAD', latest_snapshot_revision], + ['29', archive.CHROME_29_REVISION], ['28', archive.CHROME_28_REVISION], ['27', archive.CHROME_27_REVISION] ] @@ -171,9 +177,7 @@ def main(): if version_name == 'HEAD': version_name = version[1] download_site = archive.Site.SNAPSHOT - chrome_path = archive.DownloadChrome(version[1], - util.MakeTempDir(), - download_site) + chrome_path = DownloadChrome(version_name, version[1], download_site) code1 = RunPythonTests(chromedriver, ref_chromedriver, chrome=chrome_path, diff --git a/chrome/test/chromedriver/run_py_tests.py b/chrome/test/chromedriver/run_py_tests.py index 3752c5e041..440a3fb95a 100755 --- a/chrome/test/chromedriver/run_py_tests.py +++ b/chrome/test/chromedriver/run_py_tests.py @@ -70,12 +70,12 @@ _DESKTOP_NEGATIVE_FILTER['HEAD'] = ( 'ChromeDriverTest.testSingleTapElement', ] ) -_DESKTOP_NEGATIVE_FILTER['28'] = ( - _DESKTOP_NEGATIVE_FILTER['HEAD'] + [] -) -_DESKTOP_NEGATIVE_FILTER['27'] = ( - _DESKTOP_NEGATIVE_FILTER['HEAD'] + [] -) + + +def _GetDesktopNegativeFilter(version_name): + if version_name in _DESKTOP_NEGATIVE_FILTER: + return _DESKTOP_NEGATIVE_FILTER[version_name] + return _DESKTOP_NEGATIVE_FILTER['HEAD'] _ANDROID_NEGATIVE_FILTER = {} @@ -147,7 +147,7 @@ class ChromeDriverTest(ChromeDriverBaseTest): 'Debug') host_port = ChromeDriverTest._http_server._server.server_port ChromeDriverTest._forwarder.Run( - [(host_port, host_port)], valgrind_tools.BaseTool(), '127.0.0.1') + [(host_port, host_port)], valgrind_tools.BaseTool()) @staticmethod def GlobalTearDown(): @@ -736,7 +736,7 @@ if __name__ == '__main__': if _ANDROID_PACKAGE: negative_filter = _ANDROID_NEGATIVE_FILTER[_ANDROID_PACKAGE] else: - negative_filter = _DESKTOP_NEGATIVE_FILTER[options.chrome_version] + negative_filter = _GetDesktopNegativeFilter(options.chrome_version) options.filter = '*-' + ':__main__.'.join([''] + negative_filter) all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( diff --git a/chrome/test/chromedriver/server/chromedriver_server.cc b/chrome/test/chromedriver/server/chromedriver_server.cc index f0c4afe522..e1b35a703c 100644 --- a/chrome/test/chromedriver/server/chromedriver_server.cc +++ b/chrome/test/chromedriver/server/chromedriver_server.cc @@ -12,11 +12,11 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/strings/string_number_conversions.h" +#include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/synchronization/waitable_event.h" #include "chrome/test/chromedriver/chrome/log.h" #include "chrome/test/chromedriver/chrome/version.h" -#include "chrome/test/chromedriver/command_executor_impl.h" #include "chrome/test/chromedriver/server/http_handler.h" #include "chrome/test/chromedriver/server/http_response.h" #include "third_party/mongoose/mongoose.h" @@ -37,8 +37,8 @@ void ReadRequestBody(const struct mg_request_info* const request_info, if (request_info->http_headers[header_index].name == NULL) { break; } - if (strcmp(request_info->http_headers[header_index].name, - "Content-Length") == 0) { + if (LowerCaseEqualsASCII(request_info->http_headers[header_index].name, + "content-length")) { base::StringToInt( request_info->http_headers[header_index].value, &content_length); break; @@ -116,6 +116,26 @@ int main(int argc, char *argv[]) { std::string url_base; int http_threads = 4; base::FilePath log_path; + Log::Level log_level = Log::kError; + if (cmd_line->HasSwitch("h") || cmd_line->HasSwitch("help")) { + std::string options; + const char* kOptionAndDescriptions[] = { + "port=PORT", "port to listen on", + "log-path=FILE", "write server log to file instead of stderr, " + "increases log level to INFO", + "verbose", "log verbosely", + "silent", "log nothing", + "url-base", "base URL path prefix for commands, e.g. wd/url", + "http-threads=THREAD_COUNT", "number of HTTP threads to spawn", + }; + for (size_t i = 0; i < arraysize(kOptionAndDescriptions) - 1; i += 2) { + options += base::StringPrintf( + " --%-30s%s\n", + kOptionAndDescriptions[i], kOptionAndDescriptions[i + 1]); + } + printf("Usage: %s [OPTIONS]\n\nOptions\n%s", argv[0], options.c_str()); + return 0; + } if (cmd_line->HasSwitch("port")) port = cmd_line->GetSwitchValueASCII("port"); if (cmd_line->HasSwitch("url-base")) @@ -132,6 +152,7 @@ int main(int argc, char *argv[]) { } } if (cmd_line->HasSwitch("log-path")) { + log_level = Log::kLog; log_path = cmd_line->GetSwitchValuePath("log-path"); #if defined(OS_WIN) FILE* redir_stderr = _wfreopen(log_path.value().c_str(), L"w", stderr); @@ -143,13 +164,12 @@ int main(int argc, char *argv[]) { return 1; } } + if (cmd_line->HasSwitch("verbose")) + log_level = Log::kDebug; - bool success = InitLogging( - NULL, - logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, - logging::DONT_LOCK_LOG_FILE, - logging::DELETE_OLD_LOG_FILE, - logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); + logging::LoggingSettings settings; + settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; + bool success = logging::InitLogging(settings); if (!success) { PLOG(ERROR) << "Unable to initialize logging"; } @@ -157,14 +177,11 @@ int main(int argc, char *argv[]) { false, // enable_thread_id false, // enable_timestamp false); // enable_tickcount - Log::Level level = Log::kLog; - if (cmd_line->HasSwitch("verbose")) - level = Log::kDebug; + if (!cmd_line->HasSwitch("verbose")) + logging::SetMinLogLevel(logging::LOG_FATAL); - scoped_ptr<Log> log(new Logger(level)); - scoped_ptr<CommandExecutor> executor(new CommandExecutorImpl(log.get())); - HttpHandler handler( - log.get(), executor.Pass(), HttpHandler::CreateCommandMap(), url_base); + scoped_ptr<Log> log(new Logger(log_level)); + HttpHandler handler(log.get(), url_base); base::WaitableEvent shutdown_event(false, false); MongooseUserData user_data = { &handler, &shutdown_event }; @@ -180,7 +197,7 @@ int main(int argc, char *argv[]) { &user_data, options.get()); if (ctx == NULL) { - printf("Port already in use. Exiting...\n"); + printf("Port not available. Exiting...\n"); return 1; } @@ -188,6 +205,7 @@ int main(int argc, char *argv[]) { printf("Started ChromeDriver (v%s) on port %s\n", kChromeDriverVersion, port.c_str()); + fflush(stdout); } #if defined(OS_POSIX) diff --git a/chrome/test/chromedriver/server/http_handler.cc b/chrome/test/chromedriver/server/http_handler.cc index 66d515fb9f..e6fabb29f1 100644 --- a/chrome/test/chromedriver/server/http_handler.cc +++ b/chrome/test/chromedriver/server/http_handler.cc @@ -4,24 +4,53 @@ #include "chrome/test/chromedriver/server/http_handler.h" +#include "base/bind.h" +#include "base/callback.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" +#include "base/logging.h" // For CHECK macros. #include "base/memory/scoped_ptr.h" +#include "base/message_loop.h" +#include "base/message_loop/message_loop_proxy.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" +#include "base/sys_info.h" #include "base/values.h" +#include "chrome/test/chromedriver/alert_commands.h" +#include "chrome/test/chromedriver/chrome/adb_impl.h" +#include "chrome/test/chromedriver/chrome/device_manager.h" #include "chrome/test/chromedriver/chrome/log.h" #include "chrome/test/chromedriver/chrome/status.h" -#include "chrome/test/chromedriver/command_executor.h" -#include "chrome/test/chromedriver/command_names.h" +#include "chrome/test/chromedriver/chrome/version.h" +#include "chrome/test/chromedriver/commands.h" +#include "chrome/test/chromedriver/element_commands.h" +#include "chrome/test/chromedriver/net/url_request_context_getter.h" #include "chrome/test/chromedriver/server/http_response.h" +#include "chrome/test/chromedriver/session.h" +#include "chrome/test/chromedriver/session_commands.h" +#include "chrome/test/chromedriver/session_map.h" #include "chrome/test/chromedriver/util.h" +#include "chrome/test/chromedriver/window_commands.h" + +#if defined(OS_MACOSX) +#include "base/mac/scoped_nsautorelease_pool.h" +#endif namespace { +const char kLocalStorage[] = "localStorage"; +const char kSessionStorage[] = "sessionStorage"; const char kShutdownPath[] = "shutdown"; +Status UnimplementedCommand( + const base::DictionaryValue& params, + const std::string& session_id, + scoped_ptr<base::Value>* value, + std::string* out_session_id) { + return Status(kUnknownCommand); +} + } // namespace HttpRequest::HttpRequest(HttpMethod method, @@ -33,236 +62,283 @@ HttpRequest::~HttpRequest() {} CommandMapping::CommandMapping(HttpMethod method, const std::string& path_pattern, - const std::string& name) - : method(method), path_pattern(path_pattern), name(name) {} + const Command& command) + : method(method), path_pattern(path_pattern), command(command) {} CommandMapping::~CommandMapping() {} -// static -scoped_ptr<HttpHandler::CommandMap> HttpHandler::CreateCommandMap() { +HttpHandler::HttpHandler(Log* log, const std::string& url_base) + : log_(log), + io_thread_("ChromeDriver IO"), + url_base_(url_base) { +#if defined(OS_MACOSX) + base::mac::ScopedNSAutoreleasePool autorelease_pool; +#endif + base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); + CHECK(io_thread_.StartWithOptions(options)); + context_getter_ = new URLRequestContextGetter( + io_thread_.message_loop_proxy()); + socket_factory_ = CreateSyncWebSocketFactory(context_getter_.get()); + adb_.reset(new AdbImpl(io_thread_.message_loop_proxy(), log_)); + device_manager_.reset(new DeviceManager(adb_.get())); + CommandMapping commands[] = { - CommandMapping(kPost, "session", CommandNames::kNewSession), + CommandMapping(kPost, internal::kNewSessionPathPattern, + base::Bind(&ExecuteNewSession, + NewSessionParams(log_, &session_map_, + context_getter_, socket_factory_, + device_manager_.get()))), CommandMapping(kGet, "session/:sessionId", - CommandNames::kGetSessionCapabilities), - CommandMapping(kDelete, "session/:sessionId", CommandNames::kQuit), + WrapToCommand( + base::Bind(&ExecuteGetSessionCapabilities, + &session_map_))), + CommandMapping(kDelete, "session/:sessionId", + base::Bind(&ExecuteQuit, false, &session_map_)), CommandMapping(kGet, "session/:sessionId/window_handle", - CommandNames::kGetCurrentWindowHandle), + WrapToCommand(base::Bind(&ExecuteGetCurrentWindowHandle))), CommandMapping(kGet, "session/:sessionId/window_handles", - CommandNames::kGetWindowHandles), - CommandMapping(kPost, "session/:sessionId/url", CommandNames::kGet), - CommandMapping(kGet, "session/:sessionId/alert", CommandNames::kGetAlert), + WrapToCommand(base::Bind(&ExecuteGetWindowHandles))), + CommandMapping(kPost, "session/:sessionId/url", + WrapToCommand(base::Bind(&ExecuteGet))), + CommandMapping(kGet, "session/:sessionId/alert", + WrapToCommand( + base::Bind(&ExecuteAlertCommand, + base::Bind(&ExecuteGetAlert)))), CommandMapping(kPost, "session/:sessionId/dismiss_alert", - CommandNames::kDismissAlert), + WrapToCommand( + base::Bind(&ExecuteAlertCommand, + base::Bind(&ExecuteDismissAlert)))), CommandMapping(kPost, "session/:sessionId/accept_alert", - CommandNames::kAcceptAlert), + WrapToCommand( + base::Bind(&ExecuteAlertCommand, + base::Bind(&ExecuteAcceptAlert)))), CommandMapping(kGet, "session/:sessionId/alert_text", - CommandNames::kGetAlertText), + WrapToCommand( + base::Bind(&ExecuteAlertCommand, + base::Bind(&ExecuteGetAlertText)))), CommandMapping(kPost, "session/:sessionId/alert_text", - CommandNames::kSetAlertValue), + WrapToCommand( + base::Bind(&ExecuteAlertCommand, + base::Bind(&ExecuteSetAlertValue)))), CommandMapping(kPost, "session/:sessionId/forward", - CommandNames::kGoForward), - CommandMapping(kPost, "session/:sessionId/back", CommandNames::kGoBack), + WrapToCommand(base::Bind(&ExecuteGoForward))), + CommandMapping(kPost, "session/:sessionId/back", + WrapToCommand(base::Bind(&ExecuteGoBack))), CommandMapping(kPost, "session/:sessionId/refresh", - CommandNames::kRefresh), + WrapToCommand(base::Bind(&ExecuteRefresh))), CommandMapping(kPost, "session/:sessionId/execute", - CommandNames::kExecuteScript), + WrapToCommand(base::Bind(&ExecuteExecuteScript))), CommandMapping(kPost, "session/:sessionId/execute_async", - CommandNames::kExecuteAsyncScript), + WrapToCommand(base::Bind(&ExecuteExecuteAsyncScript))), CommandMapping(kGet, "session/:sessionId/url", - CommandNames::kGetCurrentUrl), - CommandMapping(kGet, "session/:sessionId/title", CommandNames::kGetTitle), + WrapToCommand(base::Bind(&ExecuteGetCurrentUrl))), + CommandMapping(kGet, "session/:sessionId/title", + WrapToCommand(base::Bind(&ExecuteGetTitle))), CommandMapping(kGet, "session/:sessionId/source", - CommandNames::kGetPageSource), + WrapToCommand(base::Bind(&ExecuteGetPageSource))), CommandMapping(kGet, "session/:sessionId/screenshot", - CommandNames::kScreenshot), + WrapToCommand(base::Bind(&ExecuteScreenshot))), CommandMapping(kPost, "session/:sessionId/visible", - CommandNames::kSetBrowserVisible), + base::Bind(&UnimplementedCommand)), CommandMapping(kGet, "session/:sessionId/visible", - CommandNames::kIsBrowserVisible), + base::Bind(&UnimplementedCommand)), CommandMapping(kPost, "session/:sessionId/element", - CommandNames::kFindElement), + WrapToCommand(base::Bind(&ExecuteFindElement, 50))), CommandMapping(kPost, "session/:sessionId/elements", - CommandNames::kFindElements), + WrapToCommand(base::Bind(&ExecuteFindElements, 50))), CommandMapping(kPost, "session/:sessionId/element/active", - CommandNames::kGetActiveElement), + WrapToCommand(base::Bind(&ExecuteGetActiveElement))), CommandMapping(kPost, "session/:sessionId/element/:id/element", - CommandNames::kFindChildElement), + WrapToCommand(base::Bind(&ExecuteFindChildElement, 50))), CommandMapping(kPost, "session/:sessionId/element/:id/elements", - CommandNames::kFindChildElements), + WrapToCommand(base::Bind(&ExecuteFindChildElements, 50))), CommandMapping(kPost, "session/:sessionId/element/:id/click", - CommandNames::kClickElement), + WrapToCommand(base::Bind(&ExecuteClickElement))), CommandMapping(kPost, "session/:sessionId/element/:id/clear", - CommandNames::kClearElement), + WrapToCommand(base::Bind(&ExecuteClearElement))), CommandMapping(kPost, "session/:sessionId/element/:id/submit", - CommandNames::kSubmitElement), + WrapToCommand(base::Bind(&ExecuteSubmitElement))), CommandMapping(kGet, "session/:sessionId/element/:id/text", - CommandNames::kGetElementText), + WrapToCommand(base::Bind(&ExecuteGetElementText))), CommandMapping(kPost, "session/:sessionId/element/:id/value", - CommandNames::kSendKeysToElement), + WrapToCommand(base::Bind(&ExecuteSendKeysToElement))), CommandMapping(kPost, "session/:sessionId/file", - CommandNames::kUploadFile), + WrapToCommand(base::Bind(&ExecuteUploadFile))), CommandMapping(kGet, "session/:sessionId/element/:id/value", - CommandNames::kGetElementValue), + WrapToCommand(base::Bind(&ExecuteGetElementValue))), CommandMapping(kGet, "session/:sessionId/element/:id/name", - CommandNames::kGetElementTagName), + WrapToCommand(base::Bind(&ExecuteGetElementTagName))), CommandMapping(kGet, "session/:sessionId/element/:id/selected", - CommandNames::kIsElementSelected), + WrapToCommand(base::Bind(&ExecuteIsElementSelected))), CommandMapping(kGet, "session/:sessionId/element/:id/enabled", - CommandNames::kIsElementEnabled), + WrapToCommand(base::Bind(&ExecuteIsElementEnabled))), CommandMapping(kGet, "session/:sessionId/element/:id/displayed", - CommandNames::kIsElementDisplayed), + WrapToCommand(base::Bind(&ExecuteIsElementDisplayed))), CommandMapping(kPost, "session/:sessionId/element/:id/hover", - CommandNames::kHoverOverElement), + WrapToCommand(base::Bind(&ExecuteHoverOverElement))), CommandMapping(kGet, "session/:sessionId/element/:id/location", - CommandNames::kGetElementLocation), + WrapToCommand(base::Bind(&ExecuteGetElementLocation))), CommandMapping(kGet, "session/:sessionId/element/:id/location_in_view", - CommandNames::kGetElementLocationOnceScrolledIntoView), + WrapToCommand( + base::Bind( + &ExecuteGetElementLocationOnceScrolledIntoView))), CommandMapping(kGet, "session/:sessionId/element/:id/size", - CommandNames::kGetElementSize), + WrapToCommand(base::Bind(&ExecuteGetElementSize))), CommandMapping(kGet, "session/:sessionId/element/:id/attribute/:name", - CommandNames::kGetElementAttribute), + WrapToCommand(base::Bind(&ExecuteGetElementAttribute))), CommandMapping(kGet, "session/:sessionId/element/:id/equals/:other", - CommandNames::kElementEquals), + WrapToCommand(base::Bind(&ExecuteElementEquals))), CommandMapping(kGet, "session/:sessionId/cookie", - CommandNames::kGetCookies), + WrapToCommand(base::Bind(&ExecuteGetCookies))), CommandMapping(kPost, "session/:sessionId/cookie", - CommandNames::kAddCookie), + WrapToCommand(base::Bind(&ExecuteAddCookie))), CommandMapping(kDelete, "session/:sessionId/cookie", - CommandNames::kDeleteAllCookies), + WrapToCommand(base::Bind(&ExecuteDeleteAllCookies))), CommandMapping(kDelete, "session/:sessionId/cookie/:name", - CommandNames::kDeleteCookie), + WrapToCommand(base::Bind(&ExecuteDeleteCookie))), CommandMapping(kPost, "session/:sessionId/frame", - CommandNames::kSwitchToFrame), + WrapToCommand(base::Bind(&ExecuteSwitchToFrame))), CommandMapping(kPost, "session/:sessionId/window", - CommandNames::kSwitchToWindow), + WrapToCommand(base::Bind(&ExecuteSwitchToWindow))), CommandMapping(kGet, "session/:sessionId/window/:windowHandle/size", - CommandNames::kGetWindowSize), + WrapToCommand(base::Bind(&ExecuteGetWindowSize))), CommandMapping(kGet, "session/:sessionId/window/:windowHandle/position", - CommandNames::kGetWindowPosition), + WrapToCommand(base::Bind(&ExecuteGetWindowPosition))), CommandMapping(kPost, "session/:sessionId/window/:windowHandle/size", - CommandNames::kSetWindowSize), + WrapToCommand(base::Bind(&ExecuteSetWindowSize))), CommandMapping(kPost, "session/:sessionId/window/:windowHandle/position", - CommandNames::kSetWindowPosition), + WrapToCommand(base::Bind(&ExecuteSetWindowPosition))), CommandMapping(kPost, "session/:sessionId/window/:windowHandle/maximize", - CommandNames::kMaximizeWindow), + WrapToCommand(base::Bind(&ExecuteMaximizeWindow))), CommandMapping(kDelete, "session/:sessionId/window", - CommandNames::kClose), + WrapToCommand(base::Bind(&ExecuteClose, &session_map_))), CommandMapping(kPost, "session/:sessionId/element/:id/drag", - CommandNames::kDragElement), + base::Bind(&UnimplementedCommand)), CommandMapping(kGet, "session/:sessionId/element/:id/css/:propertyName", - CommandNames::kGetElementValueOfCssProperty), + WrapToCommand( + base::Bind(&ExecuteGetElementValueOfCSSProperty))), CommandMapping(kPost, "session/:sessionId/timeouts/implicit_wait", - CommandNames::kImplicitlyWait), + WrapToCommand(base::Bind(&ExecuteImplicitlyWait))), CommandMapping(kPost, "session/:sessionId/timeouts/async_script", - CommandNames::kSetScriptTimeout), + WrapToCommand(base::Bind(&ExecuteSetScriptTimeout))), CommandMapping(kPost, "session/:sessionId/timeouts", - CommandNames::kSetTimeout), + WrapToCommand(base::Bind(&ExecuteSetTimeout))), CommandMapping(kPost, "session/:sessionId/execute_sql", - CommandNames::kExecuteSQL), + base::Bind(&UnimplementedCommand)), CommandMapping(kGet, "session/:sessionId/location", - CommandNames::kGetLocation), + WrapToCommand(base::Bind(&ExecuteGetLocation))), CommandMapping(kPost, "session/:sessionId/location", - CommandNames::kSetLocation), + WrapToCommand(base::Bind(&ExecuteSetLocation))), CommandMapping(kGet, "session/:sessionId/application_cache/status", - CommandNames::kGetStatus), + base::Bind(&ExecuteGetStatus)), CommandMapping(kGet, "session/:sessionId/browser_connection", - CommandNames::kIsBrowserOnline), + base::Bind(&UnimplementedCommand)), CommandMapping(kPost, "session/:sessionId/browser_connection", - CommandNames::kSetBrowserOnline), + base::Bind(&UnimplementedCommand)), CommandMapping(kGet, "session/:sessionId/local_storage/key/:key", - CommandNames::kGetLocalStorageItem), + WrapToCommand( + base::Bind(&ExecuteGetStorageItem, kLocalStorage))), CommandMapping(kDelete, "session/:sessionId/local_storage/key/:key", - CommandNames::kRemoveLocalStorageItem), + WrapToCommand( + base::Bind(&ExecuteRemoveStorageItem, kLocalStorage))), CommandMapping(kGet, "session/:sessionId/local_storage", - CommandNames::kGetLocalStorageKeys), + WrapToCommand( + base::Bind(&ExecuteGetStorageKeys, kLocalStorage))), CommandMapping(kPost, "session/:sessionId/local_storage", - CommandNames::kSetLocalStorageItem), + WrapToCommand( + base::Bind(&ExecuteSetStorageItem, kLocalStorage))), CommandMapping(kDelete, "session/:sessionId/local_storage", - CommandNames::kClearLocalStorage), + WrapToCommand( + base::Bind(&ExecuteClearStorage, kLocalStorage))), CommandMapping(kGet, "session/:sessionId/local_storage/size", - CommandNames::kGetLocalStorageSize), + WrapToCommand( + base::Bind(&ExecuteGetStorageSize, kLocalStorage))), CommandMapping(kGet, "session/:sessionId/session_storage/key/:key", - CommandNames::kGetSessionStorageItem), + WrapToCommand( + base::Bind(&ExecuteGetStorageItem, kSessionStorage))), CommandMapping(kDelete, "session/:sessionId/session_storage/key/:key", - CommandNames::kRemoveSessionStorageItem), + WrapToCommand( + base::Bind( + &ExecuteRemoveStorageItem, kSessionStorage))), CommandMapping(kGet, "session/:sessionId/session_storage", - CommandNames::kGetSessionStorageKey), + WrapToCommand( + base::Bind(&ExecuteGetStorageKeys, kSessionStorage))), CommandMapping(kPost, "session/:sessionId/session_storage", - CommandNames::kSetSessionStorageItem), + WrapToCommand( + base::Bind(&ExecuteSetStorageItem, kSessionStorage))), CommandMapping(kDelete, "session/:sessionId/session_storage", - CommandNames::kClearSessionStorage), + WrapToCommand( + base::Bind(&ExecuteClearStorage, kSessionStorage))), CommandMapping(kGet, "session/:sessionId/session_storage/size", - CommandNames::kGetSessionStorageSize), + WrapToCommand( + base::Bind(&ExecuteGetStorageSize, kSessionStorage))), CommandMapping(kGet, "session/:sessionId/orientation", - CommandNames::kGetScreenOrientation), + base::Bind(&UnimplementedCommand)), CommandMapping(kPost, "session/:sessionId/orientation", - CommandNames::kSetScreenOrientation), + base::Bind(&UnimplementedCommand)), CommandMapping(kPost, "session/:sessionId/click", - CommandNames::kMouseClick), + WrapToCommand(base::Bind(&ExecuteMouseClick))), CommandMapping(kPost, "session/:sessionId/doubleclick", - CommandNames::kMouseDoubleClick), + WrapToCommand(base::Bind(&ExecuteMouseDoubleClick))), CommandMapping(kPost, "session/:sessionId/buttondown", - CommandNames::kMouseButtonDown), + WrapToCommand(base::Bind(&ExecuteMouseButtonDown))), CommandMapping(kPost, "session/:sessionId/buttonup", - CommandNames::kMouseButtonUp), + WrapToCommand(base::Bind(&ExecuteMouseButtonUp))), CommandMapping(kPost, "session/:sessionId/moveto", - CommandNames::kMouseMoveTo), + WrapToCommand(base::Bind(&ExecuteMouseMoveTo))), CommandMapping(kPost, "session/:sessionId/keys", - CommandNames::kSendKeysToActiveElement), + WrapToCommand( + base::Bind(&ExecuteSendKeysToActiveElement))), CommandMapping(kGet, "session/:sessionId/ime/available_engines", - CommandNames::kImeGetAvailableEngines), + base::Bind(&UnimplementedCommand)), CommandMapping(kGet, "session/:sessionId/ime/active_engine", - CommandNames::kImeGetActiveEngine), + base::Bind(&UnimplementedCommand)), CommandMapping(kGet, "session/:sessionId/ime/activated", - CommandNames::kImeIsActivated), + base::Bind(&UnimplementedCommand)), CommandMapping(kPost, "session/:sessionId/ime/deactivate", - CommandNames::kImeDeactivate), + base::Bind(&UnimplementedCommand)), CommandMapping(kPost, "session/:sessionId/ime/activate", - CommandNames::kImeActivateEngine), + base::Bind(&UnimplementedCommand)), CommandMapping(kPost, "session/:sessionId/touch/click", - CommandNames::kTouchSingleTap), + WrapToCommand(base::Bind(&ExecuteTouchSingleTap))), CommandMapping(kPost, "session/:sessionId/touch/down", - CommandNames::kTouchDown), + base::Bind(&UnimplementedCommand)), CommandMapping(kPost, "session/:sessionId/touch/up", - CommandNames::kTouchUp), + base::Bind(&UnimplementedCommand)), CommandMapping(kPost, "session/:sessionId/touch/move", - CommandNames::kTouchMove), + base::Bind(&UnimplementedCommand)), CommandMapping(kPost, "session/:sessionId/touch/scroll", - CommandNames::kTouchScroll), + base::Bind(&UnimplementedCommand)), CommandMapping(kPost, "session/:sessionId/touch/doubleclick", - CommandNames::kTouchDoubleTap), + base::Bind(&UnimplementedCommand)), CommandMapping(kPost, "session/:sessionId/touch/longclick", - CommandNames::kTouchLongPress), + base::Bind(&UnimplementedCommand)), CommandMapping(kPost, "session/:sessionId/touch/flick", - CommandNames::kTouchFlick), - CommandMapping(kPost, "session/:sessionId/log", CommandNames::kGetLog), + base::Bind(&UnimplementedCommand)), + CommandMapping(kPost, "session/:sessionId/log", + WrapToCommand(base::Bind(&ExecuteGetLog))), CommandMapping(kGet, "session/:sessionId/log/types", - CommandNames::kGetAvailableLogTypes), - CommandMapping(kPost, "logs", CommandNames::kGetSessionLogs), - CommandMapping(kGet, "status", CommandNames::kStatus), + WrapToCommand(base::Bind(&ExecuteGetAvailableLogTypes))), + CommandMapping(kPost, "logs", base::Bind(&UnimplementedCommand)), + CommandMapping(kGet, "status", base::Bind(&ExecuteGetStatus)), // Custom Chrome commands: // Allow quit all to be called with GET or POST. - CommandMapping(kGet, kShutdownPath, CommandNames::kQuitAll), - CommandMapping(kPost, kShutdownPath, CommandNames::kQuitAll), + CommandMapping(kGet, kShutdownPath, + base::Bind(&ExecuteQuitAll, + base::Bind(&ExecuteQuit, true, &session_map_), + &session_map_)), + CommandMapping(kPost, kShutdownPath, + base::Bind(&ExecuteQuitAll, + base::Bind(&ExecuteQuit, true, &session_map_), + &session_map_)), CommandMapping(kGet, "session/:sessionId/is_loading", - CommandNames::kIsLoading), + WrapToCommand(base::Bind(&ExecuteIsLoading))), }; - return scoped_ptr<CommandMap>( + this->command_map_.reset( new CommandMap(commands, commands + arraysize(commands))); } -HttpHandler::HttpHandler(Log* log, - scoped_ptr<CommandExecutor> executor, - scoped_ptr<CommandMap> command_map, - const std::string& url_base) - : log_(log), - executor_(executor.Pass()), - command_map_(command_map.Pass()), - url_base_(url_base) { - executor_->Init(); -} - HttpHandler::~HttpHandler() {} void HttpHandler::Handle(const HttpRequest& request, @@ -292,6 +368,23 @@ bool HttpHandler::ShouldShutdown(const HttpRequest& request) { return request.path == url_base_ + kShutdownPath; } +Command HttpHandler::WrapToCommand( + const SessionCommand& session_command) { + return base::Bind(&ExecuteSessionCommand, &session_map_, session_command); +} + +Command HttpHandler::WrapToCommand( + const WindowCommand& window_command) { + return WrapToCommand( + base::Bind(&ExecuteWindowCommand, window_command)); +} + +Command HttpHandler::WrapToCommand( + const ElementCommand& element_command) { + return WrapToCommand( + base::Bind(&ExecuteElementCommand, element_command)); +} + void HttpHandler::HandleInternal(const HttpRequest& request, HttpResponse* response) { std::string path = request.path; @@ -339,29 +432,40 @@ bool HttpHandler::HandleWebDriverCommand( params.MergeDictionary(body_params); } - StatusCode status = kOk; scoped_ptr<base::Value> value; std::string out_session_id; - executor_->ExecuteCommand( - iter->name, params, session_id, &status, &value, &out_session_id); + Status status = iter->command.Run( + params, session_id, &value, &out_session_id); - if (status == kUnknownCommand) { + if (status.code() == kUnknownCommand) { *response = HttpResponse(HttpResponse::kNotImplemented); - response->set_body("unimplemented command: " + iter->name); + response->set_body("unimplemented command: " + trimmed_path); return true; } - if (iter->name == CommandNames::kNewSession && status == kOk) { + if (iter->path_pattern == internal::kNewSessionPathPattern && status.IsOk()) { // Creating a session involves a HTTP request to /session, which is // supposed to redirect to /session/:sessionId, which returns the // session info. *response = HttpResponse(HttpResponse::kSeeOther); response->AddHeader("Location", url_base_ + "session/" + out_session_id); return true; + } else if (status.IsError()) { + status.AddDetails(base::StringPrintf( + "Driver info: chromedriver=%s,platform=%s %s %s", + kChromeDriverVersion, + base::SysInfo::OperatingSystemName().c_str(), + base::SysInfo::OperatingSystemVersion().c_str(), + base::SysInfo::OperatingSystemArchitecture().c_str())); + scoped_ptr<base::DictionaryValue> error(new base::DictionaryValue()); + error->SetString("message", status.message()); + value.reset(error.release()); } + if (!value) + value.reset(base::Value::CreateNullValue()); base::DictionaryValue body_params; - body_params.SetInteger("status", status); + body_params.SetInteger("status", status.code()); body_params.Set("value", value.release()); body_params.SetString("sessionId", out_session_id); std::string body; @@ -376,6 +480,8 @@ bool HttpHandler::HandleWebDriverCommand( namespace internal { +const char kNewSessionPathPattern[] = "session"; + bool MatchesCommand(HttpMethod method, const std::string& path, const CommandMapping& command, @@ -410,4 +516,4 @@ bool MatchesCommand(HttpMethod method, return true; } -} // namespace +} // namespace internal diff --git a/chrome/test/chromedriver/server/http_handler.h b/chrome/test/chromedriver/server/http_handler.h index b7ff044c93..4666c5901d 100644 --- a/chrome/test/chromedriver/server/http_handler.h +++ b/chrome/test/chromedriver/server/http_handler.h @@ -8,15 +8,26 @@ #include <string> #include <vector> +#include "base/compiler_specific.h" +#include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" +#include "base/threading/thread.h" +#include "chrome/test/chromedriver/command.h" +#include "chrome/test/chromedriver/element_commands.h" +#include "chrome/test/chromedriver/net/sync_websocket_factory.h" +#include "chrome/test/chromedriver/session_commands.h" +#include "chrome/test/chromedriver/session_map.h" +#include "chrome/test/chromedriver/window_commands.h" namespace base { class DictionaryValue; } -class CommandExecutor; -class HttpResponse; +class Adb; +class DeviceManager; class Log; +class HttpResponse; +class URLRequestContextGetter; enum HttpMethod { kGet = 0, @@ -38,51 +49,62 @@ struct HttpRequest { struct CommandMapping { CommandMapping(HttpMethod method, const std::string& path_pattern, - const std::string& name); + const Command& command); ~CommandMapping(); HttpMethod method; std::string path_pattern; - std::string name; + Command command; }; class HttpHandler { public: - typedef std::vector<CommandMapping> CommandMap; - static scoped_ptr<CommandMap> CreateCommandMap(); - - HttpHandler(Log* log, - scoped_ptr<CommandExecutor> executor, - scoped_ptr<std::vector<CommandMapping> > commands, - const std::string& url_base); + HttpHandler(Log* log, const std::string& url_base); ~HttpHandler(); - void Handle(const HttpRequest& request, - HttpResponse* response); - + void Handle(const HttpRequest& request, HttpResponse* response); bool ShouldShutdown(const HttpRequest& request); private: - void HandleInternal(const HttpRequest& request, - HttpResponse* response); + FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleUnknownCommand); + FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleNewSession); + FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleInvalidPost); + FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleUnimplementedCommand); + FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleCommand); + typedef std::vector<CommandMapping> CommandMap; + + Command WrapToCommand(const SessionCommand& session_command); + Command WrapToCommand(const WindowCommand& window_command); + Command WrapToCommand(const ElementCommand& element_command); + void HandleInternal(const HttpRequest& request, HttpResponse* response); bool HandleWebDriverCommand( const HttpRequest& request, const std::string& trimmed_path, HttpResponse* response); Log* log_; - scoped_ptr<CommandExecutor> executor_; - scoped_ptr<CommandMap> command_map_; + base::Thread io_thread_; std::string url_base_; + scoped_refptr<URLRequestContextGetter> context_getter_; + SyncWebSocketFactory socket_factory_; + SessionMap session_map_; + scoped_ptr<CommandMap> command_map_; + scoped_ptr<Adb> adb_; + scoped_ptr<DeviceManager> device_manager_; + + DISALLOW_COPY_AND_ASSIGN(HttpHandler); }; namespace internal { -extern const char kNewSessionIdCommand[]; + +extern const char kNewSessionPathPattern[]; + bool MatchesCommand(HttpMethod method, const std::string& path, const CommandMapping& command, std::string* session_id, base::DictionaryValue* out_params); + } // namespace internal #endif // CHROME_TEST_CHROMEDRIVER_SERVER_HTTP_HANDLER_H_ diff --git a/chrome/test/chromedriver/server/http_handler_unittest.cc b/chrome/test/chromedriver/server/http_handler_unittest.cc index d862e6b112..816cb3e28a 100644 --- a/chrome/test/chromedriver/server/http_handler_unittest.cc +++ b/chrome/test/chromedriver/server/http_handler_unittest.cc @@ -4,50 +4,34 @@ #include <string> +#include "base/bind.h" #include "base/json/json_writer.h" #include "base/memory/scoped_ptr.h" #include "base/values.h" #include "chrome/test/chromedriver/chrome/log.h" #include "chrome/test/chromedriver/chrome/status.h" -#include "chrome/test/chromedriver/command_executor.h" -#include "chrome/test/chromedriver/command_names.h" #include "chrome/test/chromedriver/server/http_handler.h" #include "chrome/test/chromedriver/server/http_response.h" #include "testing/gtest/include/gtest/gtest.h" namespace { -class DummyExecutor : public CommandExecutor { - public: - DummyExecutor() : status_(kOk) {} - explicit DummyExecutor(StatusCode status) : status_(status) {} - virtual ~DummyExecutor() {} - - virtual void Init() OVERRIDE {} - virtual void ExecuteCommand(const std::string& name, - const base::DictionaryValue& params, - const std::string& session_id, - StatusCode* status, - scoped_ptr<base::Value>* value, - std::string* out_session_id) OVERRIDE { - *status = status_; - value->reset(new base::FundamentalValue(1)); - *out_session_id = "session_id"; - } - - private: - StatusCode status_; -}; +Status DummyCommand( + Status status, + const base::DictionaryValue& params, + const std::string& session_id, + scoped_ptr<base::Value>* value, + std::string* out_session_id) { + value->reset(new base::FundamentalValue(1)); + *out_session_id = "session_id"; + return status; +} } // namespace TEST(HttpHandlerTest, HandleOutsideOfBaseUrl) { Logger log; - HttpHandler handler( - &log, - scoped_ptr<CommandExecutor>(new DummyExecutor()), - scoped_ptr<HttpHandler::CommandMap>(new HttpHandler::CommandMap()), - "base/url/"); + HttpHandler handler(&log, "base/url/"); HttpRequest request(kGet, "base/path", "body"); HttpResponse response; handler.Handle(request, &response); @@ -56,11 +40,7 @@ TEST(HttpHandlerTest, HandleOutsideOfBaseUrl) { TEST(HttpHandlerTest, HandleUnknownCommand) { Logger log; - HttpHandler handler( - &log, - scoped_ptr<CommandExecutor>(new DummyExecutor()), - scoped_ptr<HttpHandler::CommandMap>(new HttpHandler::CommandMap()), - "/"); + HttpHandler handler(&log, "/"); HttpRequest request(kGet, "/path", std::string()); HttpResponse response; handler.Handle(request, &response); @@ -68,13 +48,12 @@ TEST(HttpHandlerTest, HandleUnknownCommand) { } TEST(HttpHandlerTest, HandleNewSession) { - scoped_ptr<HttpHandler::CommandMap> map(new HttpHandler::CommandMap()); - map->push_back(CommandMapping(kPost, "session", CommandNames::kNewSession)); Logger log; - HttpHandler handler( - &log, - scoped_ptr<CommandExecutor>(new DummyExecutor()), - map.Pass(), "/base/"); + HttpHandler handler(&log, "/base/"); + handler.command_map_.reset(new HttpHandler::CommandMap()); + handler.command_map_->push_back( + CommandMapping(kPost, internal::kNewSessionPathPattern, + base::Bind(&DummyCommand, Status(kOk)))); HttpRequest request(kPost, "/base/session", std::string()); HttpResponse response; handler.Handle(request, &response); @@ -86,13 +65,10 @@ TEST(HttpHandlerTest, HandleNewSession) { } TEST(HttpHandlerTest, HandleInvalidPost) { - scoped_ptr<HttpHandler::CommandMap> map(new HttpHandler::CommandMap()); - map->push_back(CommandMapping(kPost, "path", "cmd")); Logger log; - HttpHandler handler( - &log, - scoped_ptr<CommandExecutor>(new DummyExecutor()), - map.Pass(), "/"); + HttpHandler handler(&log, "/"); + handler.command_map_->push_back( + CommandMapping(kPost, "path", base::Bind(&DummyCommand, Status(kOk)))); HttpRequest request(kPost, "/path", "should be a dictionary"); HttpResponse response; handler.Handle(request, &response); @@ -100,13 +76,11 @@ TEST(HttpHandlerTest, HandleInvalidPost) { } TEST(HttpHandlerTest, HandleUnimplementedCommand) { - scoped_ptr<HttpHandler::CommandMap> map(new HttpHandler::CommandMap()); - map->push_back(CommandMapping(kPost, "path", "cmd")); Logger log; - HttpHandler handler( - &log, - scoped_ptr<CommandExecutor>(new DummyExecutor(kUnknownCommand)), - map.Pass(), "/"); + HttpHandler handler(&log, "/"); + handler.command_map_->push_back( + CommandMapping(kPost, "path", + base::Bind(&DummyCommand, Status(kUnknownCommand)))); HttpRequest request(kPost, "/path", std::string()); HttpResponse response; handler.Handle(request, &response); @@ -114,13 +88,10 @@ TEST(HttpHandlerTest, HandleUnimplementedCommand) { } TEST(HttpHandlerTest, HandleCommand) { - scoped_ptr<HttpHandler::CommandMap> map(new HttpHandler::CommandMap()); - map->push_back(CommandMapping(kPost, "path", "cmd")); Logger log; - HttpHandler handler( - &log, - scoped_ptr<CommandExecutor>(new DummyExecutor()), - map.Pass(), "/"); + HttpHandler handler(&log, "/"); + handler.command_map_->push_back( + CommandMapping(kPost, "path", base::Bind(&DummyCommand, Status(kOk)))); HttpRequest request(kPost, "/path", std::string()); HttpResponse response; handler.Handle(request, &response); @@ -137,7 +108,7 @@ TEST(HttpHandlerTest, HandleCommand) { } TEST(MatchesCommandTest, DiffMethod) { - CommandMapping command(kPost, "path", "command"); + CommandMapping command(kPost, "path", base::Bind(&DummyCommand, Status(kOk))); std::string session_id; base::DictionaryValue params; ASSERT_FALSE(internal::MatchesCommand( @@ -147,7 +118,8 @@ TEST(MatchesCommandTest, DiffMethod) { } TEST(MatchesCommandTest, DiffPathLength) { - CommandMapping command(kPost, "path/path", "command"); + CommandMapping command(kPost, "path/path", + base::Bind(&DummyCommand, Status(kOk))); std::string session_id; base::DictionaryValue params; ASSERT_FALSE(internal::MatchesCommand( @@ -161,7 +133,8 @@ TEST(MatchesCommandTest, DiffPathLength) { } TEST(MatchesCommandTest, DiffPaths) { - CommandMapping command(kPost, "path/apath", "command"); + CommandMapping command(kPost, "path/apath", + base::Bind(&DummyCommand, Status(kOk))); std::string session_id; base::DictionaryValue params; ASSERT_FALSE(internal::MatchesCommand( @@ -169,7 +142,8 @@ TEST(MatchesCommandTest, DiffPaths) { } TEST(MatchesCommandTest, Substitution) { - CommandMapping command(kPost, "path/:sessionId/space/:a/:b", "command"); + CommandMapping command(kPost, "path/:sessionId/space/:a/:b", + base::Bind(&DummyCommand, Status(kOk))); std::string session_id; base::DictionaryValue params; ASSERT_TRUE(internal::MatchesCommand( diff --git a/chrome/test/chromedriver/test_environment.py b/chrome/test/chromedriver/test_environment.py index 396aef36fe..e34b4c884d 100644 --- a/chrome/test/chromedriver/test_environment.py +++ b/chrome/test/chromedriver/test_environment.py @@ -11,11 +11,9 @@ tests in various environments. import os import sys -_THIS_DIR = os.path.abspath(os.path.dirname(__file__)) - -sys.path.insert(0, os.path.join(_THIS_DIR, os.pardir, 'pylib')) +import util -from common import util +_THIS_DIR = os.path.abspath(os.path.dirname(__file__)) if util.IsLinux(): sys.path.insert(0, os.path.join(_THIS_DIR, os.pardir, os.pardir, os.pardir, @@ -78,7 +76,7 @@ class BaseTestEnvironment(object): class DesktopTestEnvironment(BaseTestEnvironment): """Manages the environment java tests require to run on Desktop.""" - #override + # override def GetOS(self): return util.GetPlatformName() @@ -91,7 +89,7 @@ class AndroidTestEnvironment(DesktopTestEnvironment): self._adb = None self._forwarder = None - #override + # override def GlobalSetUp(self): os.putenv('TEST_HTTP_PORT', str(ANDROID_TEST_HTTP_PORT)) os.putenv('TEST_HTTPS_PORT', str(ANDROID_TEST_HTTPS_PORT)) @@ -100,15 +98,15 @@ class AndroidTestEnvironment(DesktopTestEnvironment): self._forwarder.Run( [(ANDROID_TEST_HTTP_PORT, ANDROID_TEST_HTTP_PORT), (ANDROID_TEST_HTTPS_PORT, ANDROID_TEST_HTTPS_PORT)], - valgrind_tools.BaseTool(), '127.0.0.1') + valgrind_tools.BaseTool()) - #override + # override def GlobalTearDown(self): if self._adb is not None: forwarder.Forwarder.KillDevice(self._adb, valgrind_tools.BaseTool()) if self._forwarder is not None: self._forwarder.Close() - #override + # override def GetOS(self): return 'android' diff --git a/chrome/test/chromedriver/test_expectations b/chrome/test/chromedriver/test_expectations index 1ada19932e..b35023c839 100644 --- a/chrome/test/chromedriver/test_expectations +++ b/chrome/test/chromedriver/test_expectations @@ -88,8 +88,7 @@ _REVISION_NEGATIVE_FILTER['HEAD'] = [ 'VisibilityTest.tooSmallAWindowWithOverflowHiddenIsNotAProblem', 'WindowTest.*', ] -_REVISION_NEGATIVE_FILTER['28'] = [] + _REVISION_NEGATIVE_FILTER['HEAD'] -_REVISION_NEGATIVE_FILTER['27'] = [] + _REVISION_NEGATIVE_FILTER['HEAD'] + _OS_NEGATIVE_FILTER = {} _OS_NEGATIVE_FILTER['win'] = [ @@ -159,6 +158,13 @@ _OS_NEGATIVE_FILTER['android'] = [ 'WindowSwitchingTest.*', ] + +def _GetRevisionNegativeFilter(chrome_version): + if chrome_version in _REVISION_NEGATIVE_FILTER: + return _REVISION_NEGATIVE_FILTER[chrome_version] + return _REVISION_NEGATIVE_FILTER['HEAD'] + + def GetDisabledTestMatchers(operating_system, chrome_version): """Returns the list of disabled test matchers for the specific configuration. @@ -171,7 +177,8 @@ def GetDisabledTestMatchers(operating_system, chrome_version): List of disabled test matchers, which may contain '*' wildcards. """ return (_OS_NEGATIVE_FILTER[operating_system] + - _REVISION_NEGATIVE_FILTER[chrome_version])[:] + _GetRevisionNegativeFilter(chrome_version))[:] + def ApplyJavaTestFilter(operating_system, chrome_version, tests): """Applies the test filter to the given list of tests. @@ -186,7 +193,7 @@ def ApplyJavaTestFilter(operating_system, chrome_version, tests): Set of passed test names. """ filters = (_OS_NEGATIVE_FILTER[operating_system] + - _REVISION_NEGATIVE_FILTER[chrome_version]) + _GetRevisionNegativeFilter(chrome_version)) passed = set(tests) for f in filters: passed.difference_update(set(t for t in tests if fnmatch.fnmatch(t, f))) diff --git a/chrome/test/chromedriver/test_util.cc b/chrome/test/chromedriver/test_util.cc index 4d2d3c662a..14f1c74986 100644 --- a/chrome/test/chromedriver/test_util.cc +++ b/chrome/test/chromedriver/test_util.cc @@ -39,15 +39,15 @@ bool SwitchKeyboardLayout(const std::string& input_locale_identifier) { #if defined(OS_MACOSX) bool SwitchKeyboardLayout(const std::string& input_source_id) { - base::mac::ScopedCFTypeRef<CFMutableDictionaryRef> filter_dict( + base::ScopedCFTypeRef<CFMutableDictionaryRef> filter_dict( CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); - base::mac::ScopedCFTypeRef<CFStringRef> id_ref(CFStringCreateWithCString( + base::ScopedCFTypeRef<CFStringRef> id_ref(CFStringCreateWithCString( kCFAllocatorDefault, input_source_id.c_str(), kCFStringEncodingUTF8)); CFDictionaryAddValue(filter_dict, kTISPropertyInputSourceID, id_ref); - base::mac::ScopedCFTypeRef<CFArrayRef> sources( + base::ScopedCFTypeRef<CFArrayRef> sources( TISCreateInputSourceList(filter_dict, true)); if (CFArrayGetCount(sources) != 1) return false; diff --git a/chrome/test/chromedriver/test_util.h b/chrome/test/chromedriver/test_util.h index 6ef821e690..e198842c31 100644 --- a/chrome/test/chromedriver/test_util.h +++ b/chrome/test/chromedriver/test_util.h @@ -27,7 +27,7 @@ class RestoreKeyboardLayoutOnDestruct { #if defined(OS_WIN) HKL layout_; #elif defined(OS_MACOSX) - base::mac::ScopedCFTypeRef<TISInputSourceRef> layout_; + base::ScopedCFTypeRef<TISInputSourceRef> layout_; #endif DISALLOW_COPY_AND_ASSIGN(RestoreKeyboardLayoutOnDestruct); diff --git a/chrome/test/chromedriver/third_party/jni/LICENSE b/chrome/test/chromedriver/third_party/jni/LICENSE deleted file mode 100644 index 80a4762430..0000000000 --- a/chrome/test/chromedriver/third_party/jni/LICENSE +++ /dev/null @@ -1,204 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2007-2009 Google Inc. - Copyright 2007-2009 WebDriver committers - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/chrome/test/chromedriver/third_party/jni/README.chromium b/chrome/test/chromedriver/third_party/jni/README.chromium deleted file mode 100644 index 8a3cc33371..0000000000 --- a/chrome/test/chromedriver/third_party/jni/README.chromium +++ /dev/null @@ -1,13 +0,0 @@ -Name: Java Native Interface from Android NDK -Short Name: JNI -URL: http://developer.android.com/sdk/index.html -Version: NDK r7, SDK API level 16 -Security Critical: no -License: Apache 2 - -Description: - An API for native code to interface with code running in a JVM. - -Local modifications: - -See patch.diff. Made portable to windows by adding proper JNICALL and - JNIEXPORT defines. diff --git a/chrome/test/chromedriver/third_party/jni/jni.gyp b/chrome/test/chromedriver/third_party/jni/jni.gyp deleted file mode 100644 index 152810ca19..0000000000 --- a/chrome/test/chromedriver/third_party/jni/jni.gyp +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2012 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. - -{ - 'targets': [{ - 'target_name': 'jni', - 'type': 'none', - 'sources': [ - 'jni.h', - ], - }], -} diff --git a/chrome/test/chromedriver/third_party/jni/jni.h b/chrome/test/chromedriver/third_party/jni/jni.h deleted file mode 100644 index 2c44f07fcb..0000000000 --- a/chrome/test/chromedriver/third_party/jni/jni.h +++ /dev/null @@ -1,1162 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * JNI specification, as defined by Sun: - * http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/jniTOC.html - * - * Everything here is expected to be VM-neutral. - */ - -#ifndef JNI_H_ -#define JNI_H_ - -#include <stdarg.h> - -#ifdef _WIN32 -#define JNIIMPORT __declspec(dllimport) -#define JNIEXPORT __declspec(dllexport) -#define JNICALL __stdcall -#else -#define JNIIMPORT -#define JNIEXPORT __attribute__ ((visibility ("default"))) -#define JNICALL -#endif - -/* - * Primitive types that match up with Java equivalents. - */ -#ifdef HAVE_INTTYPES_H -# include <inttypes.h> /* C99 */ -typedef uint8_t jboolean; /* unsigned 8 bits */ -typedef int8_t jbyte; /* signed 8 bits */ -typedef uint16_t jchar; /* unsigned 16 bits */ -typedef int16_t jshort; /* signed 16 bits */ -typedef int32_t jint; /* signed 32 bits */ -typedef int64_t jlong; /* signed 64 bits */ -typedef float jfloat; /* 32-bit IEEE 754 */ -typedef double jdouble; /* 64-bit IEEE 754 */ -#else -typedef unsigned char jboolean; /* unsigned 8 bits */ -typedef signed char jbyte; /* signed 8 bits */ -typedef unsigned short jchar; /* unsigned 16 bits */ -typedef short jshort; /* signed 16 bits */ -typedef int jint; /* signed 32 bits */ -typedef long long jlong; /* signed 64 bits */ -typedef float jfloat; /* 32-bit IEEE 754 */ -typedef double jdouble; /* 64-bit IEEE 754 */ -#endif - -/* "cardinal indices and sizes" */ -typedef jint jsize; - -#ifdef __cplusplus -/* - * Reference types, in C++ - */ -class _jobject {}; -class _jclass : public _jobject {}; -class _jstring : public _jobject {}; -class _jarray : public _jobject {}; -class _jobjectArray : public _jarray {}; -class _jbooleanArray : public _jarray {}; -class _jbyteArray : public _jarray {}; -class _jcharArray : public _jarray {}; -class _jshortArray : public _jarray {}; -class _jintArray : public _jarray {}; -class _jlongArray : public _jarray {}; -class _jfloatArray : public _jarray {}; -class _jdoubleArray : public _jarray {}; -class _jthrowable : public _jobject {}; - -typedef _jobject* jobject; -typedef _jclass* jclass; -typedef _jstring* jstring; -typedef _jarray* jarray; -typedef _jobjectArray* jobjectArray; -typedef _jbooleanArray* jbooleanArray; -typedef _jbyteArray* jbyteArray; -typedef _jcharArray* jcharArray; -typedef _jshortArray* jshortArray; -typedef _jintArray* jintArray; -typedef _jlongArray* jlongArray; -typedef _jfloatArray* jfloatArray; -typedef _jdoubleArray* jdoubleArray; -typedef _jthrowable* jthrowable; -typedef _jobject* jweak; - - -#else /* not __cplusplus */ - -/* - * Reference types, in C. - */ -typedef void* jobject; -typedef jobject jclass; -typedef jobject jstring; -typedef jobject jarray; -typedef jarray jobjectArray; -typedef jarray jbooleanArray; -typedef jarray jbyteArray; -typedef jarray jcharArray; -typedef jarray jshortArray; -typedef jarray jintArray; -typedef jarray jlongArray; -typedef jarray jfloatArray; -typedef jarray jdoubleArray; -typedef jobject jthrowable; -typedef jobject jweak; - -#endif /* not __cplusplus */ - -struct _jfieldID; /* opaque structure */ -typedef struct _jfieldID* jfieldID; /* field IDs */ - -struct _jmethodID; /* opaque structure */ -typedef struct _jmethodID* jmethodID; /* method IDs */ - -struct JNIInvokeInterface; - -typedef union jvalue { - jboolean z; - jbyte b; - jchar c; - jshort s; - jint i; - jlong j; - jfloat f; - jdouble d; - jobject l; -} jvalue; - -typedef enum jobjectRefType { - JNIInvalidRefType = 0, - JNILocalRefType = 1, - JNIGlobalRefType = 2, - JNIWeakGlobalRefType = 3 -} jobjectRefType; - -typedef struct { - const char* name; - const char* signature; - void* fnPtr; -} JNINativeMethod; - -struct _JNIEnv; -struct _JavaVM; -typedef const struct JNINativeInterface* C_JNIEnv; - -#if defined(__cplusplus) -typedef _JNIEnv JNIEnv; -typedef _JavaVM JavaVM; -#else -typedef const struct JNINativeInterface* JNIEnv; -typedef const struct JNIInvokeInterface* JavaVM; -#endif - -/* - * Table of interface function pointers. - */ -struct JNINativeInterface { - void* reserved0; - void* reserved1; - void* reserved2; - void* reserved3; - - jint (JNICALL *GetVersion)(JNIEnv *); - - jclass (JNICALL *DefineClass)(JNIEnv*, const char*, jobject, const jbyte*, - jsize); - jclass (JNICALL *FindClass)(JNIEnv*, const char*); - - jmethodID (JNICALL *FromReflectedMethod)(JNIEnv*, jobject); - jfieldID (JNICALL *FromReflectedField)(JNIEnv*, jobject); - /* spec doesn't show jboolean parameter */ - jobject (JNICALL *ToReflectedMethod)(JNIEnv*, jclass, jmethodID, jboolean); - - jclass (JNICALL *GetSuperclass)(JNIEnv*, jclass); - jboolean (JNICALL *IsAssignableFrom)(JNIEnv*, jclass, jclass); - - /* spec doesn't show jboolean parameter */ - jobject (JNICALL *ToReflectedField)(JNIEnv*, jclass, jfieldID, jboolean); - - jint (JNICALL *Throw)(JNIEnv*, jthrowable); - jint (JNICALL *ThrowNew)(JNIEnv *, jclass, const char *); - jthrowable (JNICALL *ExceptionOccurred)(JNIEnv*); - void (JNICALL *ExceptionDescribe)(JNIEnv*); - void (JNICALL *ExceptionClear)(JNIEnv*); - void (JNICALL *FatalError)(JNIEnv*, const char*); - - jint (JNICALL *PushLocalFrame)(JNIEnv*, jint); - jobject (JNICALL *PopLocalFrame)(JNIEnv*, jobject); - - jobject (JNICALL *NewGlobalRef)(JNIEnv*, jobject); - void (JNICALL *DeleteGlobalRef)(JNIEnv*, jobject); - void (JNICALL *DeleteLocalRef)(JNIEnv*, jobject); - jboolean (JNICALL *IsSameObject)(JNIEnv*, jobject, jobject); - - jobject (JNICALL *NewLocalRef)(JNIEnv*, jobject); - jint (JNICALL *EnsureLocalCapacity)(JNIEnv*, jint); - - jobject (JNICALL *AllocObject)(JNIEnv*, jclass); - jobject (JNICALL *NewObject)(JNIEnv*, jclass, jmethodID, ...); - jobject (JNICALL *NewObjectV)(JNIEnv*, jclass, jmethodID, va_list); - jobject (JNICALL *NewObjectA)(JNIEnv*, jclass, jmethodID, jvalue*); - - jclass (JNICALL *GetObjectClass)(JNIEnv*, jobject); - jboolean (JNICALL *IsInstanceOf)(JNIEnv*, jobject, jclass); - jmethodID (JNICALL *GetMethodID)(JNIEnv*, jclass, const char*, const char*); - - jobject (JNICALL *CallObjectMethod)(JNIEnv*, jobject, jmethodID, ...); - jobject (JNICALL *CallObjectMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jobject (JNICALL *CallObjectMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); - jboolean (JNICALL *CallBooleanMethod)(JNIEnv*, jobject, jmethodID, ...); - jboolean (JNICALL *CallBooleanMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jboolean (JNICALL *CallBooleanMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); - jbyte (JNICALL *CallByteMethod)(JNIEnv*, jobject, jmethodID, ...); - jbyte (JNICALL *CallByteMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jbyte (JNICALL *CallByteMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); - jchar (JNICALL *CallCharMethod)(JNIEnv*, jobject, jmethodID, ...); - jchar (JNICALL *CallCharMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jchar (JNICALL *CallCharMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); - jshort (JNICALL *CallShortMethod)(JNIEnv*, jobject, jmethodID, ...); - jshort (JNICALL *CallShortMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jshort (JNICALL *CallShortMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); - jint (JNICALL *CallIntMethod)(JNIEnv*, jobject, jmethodID, ...); - jint (JNICALL *CallIntMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jint (JNICALL *CallIntMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); - jlong (JNICALL *CallLongMethod)(JNIEnv*, jobject, jmethodID, ...); - jlong (JNICALL *CallLongMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jlong (JNICALL *CallLongMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); - jfloat (JNICALL *CallFloatMethod)(JNIEnv*, jobject, jmethodID, ...); - jfloat (JNICALL *CallFloatMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jfloat (JNICALL *CallFloatMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); - jdouble (JNICALL *CallDoubleMethod)(JNIEnv*, jobject, jmethodID, ...); - jdouble (JNICALL *CallDoubleMethodV)(JNIEnv*, jobject, jmethodID, va_list); - jdouble (JNICALL *CallDoubleMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); - void (JNICALL *CallVoidMethod)(JNIEnv*, jobject, jmethodID, ...); - void (JNICALL *CallVoidMethodV)(JNIEnv*, jobject, jmethodID, va_list); - void (JNICALL *CallVoidMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); - - jobject (JNICALL *CallNonvirtualObjectMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jobject (JNICALL *CallNonvirtualObjectMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jobject (JNICALL *CallNonvirtualObjectMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); - jboolean (JNICALL *CallNonvirtualBooleanMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jboolean (JNICALL *CallNonvirtualBooleanMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jboolean (JNICALL *CallNonvirtualBooleanMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); - jbyte (JNICALL *CallNonvirtualByteMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jbyte (JNICALL *CallNonvirtualByteMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jbyte (JNICALL *CallNonvirtualByteMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); - jchar (JNICALL *CallNonvirtualCharMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jchar (JNICALL *CallNonvirtualCharMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jchar (JNICALL *CallNonvirtualCharMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); - jshort (JNICALL *CallNonvirtualShortMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jshort (JNICALL *CallNonvirtualShortMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jshort (JNICALL *CallNonvirtualShortMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); - jint (JNICALL *CallNonvirtualIntMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jint (JNICALL *CallNonvirtualIntMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jint (JNICALL *CallNonvirtualIntMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); - jlong (JNICALL *CallNonvirtualLongMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jlong (JNICALL *CallNonvirtualLongMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jlong (JNICALL *CallNonvirtualLongMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); - jfloat (JNICALL *CallNonvirtualFloatMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jfloat (JNICALL *CallNonvirtualFloatMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jfloat (JNICALL *CallNonvirtualFloatMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); - jdouble (JNICALL *CallNonvirtualDoubleMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - jdouble (JNICALL *CallNonvirtualDoubleMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - jdouble (JNICALL *CallNonvirtualDoubleMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); - void (JNICALL *CallNonvirtualVoidMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); - void (JNICALL *CallNonvirtualVoidMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); - void (JNICALL *CallNonvirtualVoidMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); - - jfieldID (JNICALL *GetFieldID)(JNIEnv*, jclass, const char*, const char*); - - jobject (JNICALL *GetObjectField)(JNIEnv*, jobject, jfieldID); - jboolean (JNICALL *GetBooleanField)(JNIEnv*, jobject, jfieldID); - jbyte (JNICALL *GetByteField)(JNIEnv*, jobject, jfieldID); - jchar (JNICALL *GetCharField)(JNIEnv*, jobject, jfieldID); - jshort (JNICALL *GetShortField)(JNIEnv*, jobject, jfieldID); - jint (JNICALL *GetIntField)(JNIEnv*, jobject, jfieldID); - jlong (JNICALL *GetLongField)(JNIEnv*, jobject, jfieldID); - jfloat (JNICALL *GetFloatField)(JNIEnv*, jobject, jfieldID); - jdouble (JNICALL *GetDoubleField)(JNIEnv*, jobject, jfieldID); - - void (JNICALL *SetObjectField)(JNIEnv*, jobject, jfieldID, jobject); - void (JNICALL *SetBooleanField)(JNIEnv*, jobject, jfieldID, jboolean); - void (JNICALL *SetByteField)(JNIEnv*, jobject, jfieldID, jbyte); - void (JNICALL *SetCharField)(JNIEnv*, jobject, jfieldID, jchar); - void (JNICALL *SetShortField)(JNIEnv*, jobject, jfieldID, jshort); - void (JNICALL *SetIntField)(JNIEnv*, jobject, jfieldID, jint); - void (JNICALL *SetLongField)(JNIEnv*, jobject, jfieldID, jlong); - void (JNICALL *SetFloatField)(JNIEnv*, jobject, jfieldID, jfloat); - void (JNICALL *SetDoubleField)(JNIEnv*, jobject, jfieldID, jdouble); - - jmethodID (JNICALL *GetStaticMethodID)(JNIEnv*, jclass, const char*, const char*); - - jobject (JNICALL *CallStaticObjectMethod)(JNIEnv*, jclass, jmethodID, ...); - jobject (JNICALL *CallStaticObjectMethodV)(JNIEnv*, jclass, jmethodID, va_list); - jobject (JNICALL *CallStaticObjectMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); - jboolean (JNICALL *CallStaticBooleanMethod)(JNIEnv*, jclass, jmethodID, ...); - jboolean (JNICALL *CallStaticBooleanMethodV)(JNIEnv*, jclass, jmethodID, - va_list); - jboolean (JNICALL *CallStaticBooleanMethodA)(JNIEnv*, jclass, jmethodID, - jvalue*); - jbyte (JNICALL *CallStaticByteMethod)(JNIEnv*, jclass, jmethodID, ...); - jbyte (JNICALL *CallStaticByteMethodV)(JNIEnv*, jclass, jmethodID, va_list); - jbyte (JNICALL *CallStaticByteMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); - jchar (JNICALL *CallStaticCharMethod)(JNIEnv*, jclass, jmethodID, ...); - jchar (JNICALL *CallStaticCharMethodV)(JNIEnv*, jclass, jmethodID, va_list); - jchar (JNICALL *CallStaticCharMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); - jshort (JNICALL *CallStaticShortMethod)(JNIEnv*, jclass, jmethodID, ...); - jshort (JNICALL *CallStaticShortMethodV)(JNIEnv*, jclass, jmethodID, va_list); - jshort (JNICALL *CallStaticShortMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); - jint (JNICALL *CallStaticIntMethod)(JNIEnv*, jclass, jmethodID, ...); - jint (JNICALL *CallStaticIntMethodV)(JNIEnv*, jclass, jmethodID, va_list); - jint (JNICALL *CallStaticIntMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); - jlong (JNICALL *CallStaticLongMethod)(JNIEnv*, jclass, jmethodID, ...); - jlong (JNICALL *CallStaticLongMethodV)(JNIEnv*, jclass, jmethodID, va_list); - jlong (JNICALL *CallStaticLongMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); - jfloat (JNICALL *CallStaticFloatMethod)(JNIEnv*, jclass, jmethodID, ...); - jfloat (JNICALL *CallStaticFloatMethodV)(JNIEnv*, jclass, jmethodID, va_list); - jfloat (JNICALL *CallStaticFloatMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); - jdouble (JNICALL *CallStaticDoubleMethod)(JNIEnv*, jclass, jmethodID, ...); - jdouble (JNICALL *CallStaticDoubleMethodV)(JNIEnv*, jclass, jmethodID, va_list); - jdouble (JNICALL *CallStaticDoubleMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); - void (JNICALL *CallStaticVoidMethod)(JNIEnv*, jclass, jmethodID, ...); - void (JNICALL *CallStaticVoidMethodV)(JNIEnv*, jclass, jmethodID, va_list); - void (JNICALL *CallStaticVoidMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); - - jfieldID (JNICALL *GetStaticFieldID)(JNIEnv*, jclass, const char*, - const char*); - - jobject (JNICALL *GetStaticObjectField)(JNIEnv*, jclass, jfieldID); - jboolean (JNICALL *GetStaticBooleanField)(JNIEnv*, jclass, jfieldID); - jbyte (JNICALL *GetStaticByteField)(JNIEnv*, jclass, jfieldID); - jchar (JNICALL *GetStaticCharField)(JNIEnv*, jclass, jfieldID); - jshort (JNICALL *GetStaticShortField)(JNIEnv*, jclass, jfieldID); - jint (JNICALL *GetStaticIntField)(JNIEnv*, jclass, jfieldID); - jlong (JNICALL *GetStaticLongField)(JNIEnv*, jclass, jfieldID); - jfloat (JNICALL *GetStaticFloatField)(JNIEnv*, jclass, jfieldID); - jdouble (JNICALL *GetStaticDoubleField)(JNIEnv*, jclass, jfieldID); - - void (JNICALL *SetStaticObjectField)(JNIEnv*, jclass, jfieldID, jobject); - void (JNICALL *SetStaticBooleanField)(JNIEnv*, jclass, jfieldID, jboolean); - void (JNICALL *SetStaticByteField)(JNIEnv*, jclass, jfieldID, jbyte); - void (JNICALL *SetStaticCharField)(JNIEnv*, jclass, jfieldID, jchar); - void (JNICALL *SetStaticShortField)(JNIEnv*, jclass, jfieldID, jshort); - void (JNICALL *SetStaticIntField)(JNIEnv*, jclass, jfieldID, jint); - void (JNICALL *SetStaticLongField)(JNIEnv*, jclass, jfieldID, jlong); - void (JNICALL *SetStaticFloatField)(JNIEnv*, jclass, jfieldID, jfloat); - void (JNICALL *SetStaticDoubleField)(JNIEnv*, jclass, jfieldID, jdouble); - - jstring (JNICALL *NewString)(JNIEnv*, const jchar*, jsize); - jsize (JNICALL *GetStringLength)(JNIEnv*, jstring); - const jchar* (JNICALL *GetStringChars)(JNIEnv*, jstring, jboolean*); - void (JNICALL *ReleaseStringChars)(JNIEnv*, jstring, const jchar*); - jstring (JNICALL *NewStringUTF)(JNIEnv*, const char*); - jsize (JNICALL *GetStringUTFLength)(JNIEnv*, jstring); - /* JNI spec says this returns const jbyte*, but that's inconsistent */ - const char* (JNICALL *GetStringUTFChars)(JNIEnv*, jstring, jboolean*); - void (JNICALL *ReleaseStringUTFChars)(JNIEnv*, jstring, const char*); - jsize (JNICALL *GetArrayLength)(JNIEnv*, jarray); - jobjectArray (JNICALL *NewObjectArray)(JNIEnv*, jsize, jclass, jobject); - jobject (JNICALL *GetObjectArrayElement)(JNIEnv*, jobjectArray, jsize); - void (JNICALL *SetObjectArrayElement)(JNIEnv*, jobjectArray, jsize, jobject); - - jbooleanArray (JNICALL *NewBooleanArray)(JNIEnv*, jsize); - jbyteArray (JNICALL *NewByteArray)(JNIEnv*, jsize); - jcharArray (JNICALL *NewCharArray)(JNIEnv*, jsize); - jshortArray (JNICALL *NewShortArray)(JNIEnv*, jsize); - jintArray (JNICALL *NewIntArray)(JNIEnv*, jsize); - jlongArray (JNICALL *NewLongArray)(JNIEnv*, jsize); - jfloatArray (JNICALL *NewFloatArray)(JNIEnv*, jsize); - jdoubleArray (JNICALL *NewDoubleArray)(JNIEnv*, jsize); - - jboolean* (JNICALL *GetBooleanArrayElements)(JNIEnv*, jbooleanArray, jboolean*); - jbyte* (JNICALL *GetByteArrayElements)(JNIEnv*, jbyteArray, jboolean*); - jchar* (JNICALL *GetCharArrayElements)(JNIEnv*, jcharArray, jboolean*); - jshort* (JNICALL *GetShortArrayElements)(JNIEnv*, jshortArray, jboolean*); - jint* (JNICALL *GetIntArrayElements)(JNIEnv*, jintArray, jboolean*); - jlong* (JNICALL *GetLongArrayElements)(JNIEnv*, jlongArray, jboolean*); - jfloat* (JNICALL *GetFloatArrayElements)(JNIEnv*, jfloatArray, jboolean*); - jdouble* (JNICALL *GetDoubleArrayElements)(JNIEnv*, jdoubleArray, jboolean*); - - void (JNICALL *ReleaseBooleanArrayElements)(JNIEnv*, jbooleanArray, - jboolean*, jint); - void (JNICALL *ReleaseByteArrayElements)(JNIEnv*, jbyteArray, - jbyte*, jint); - void (JNICALL *ReleaseCharArrayElements)(JNIEnv*, jcharArray, - jchar*, jint); - void (JNICALL *ReleaseShortArrayElements)(JNIEnv*, jshortArray, - jshort*, jint); - void (JNICALL *ReleaseIntArrayElements)(JNIEnv*, jintArray, - jint*, jint); - void (JNICALL *ReleaseLongArrayElements)(JNIEnv*, jlongArray, - jlong*, jint); - void (JNICALL *ReleaseFloatArrayElements)(JNIEnv*, jfloatArray, - jfloat*, jint); - void (JNICALL *ReleaseDoubleArrayElements)(JNIEnv*, jdoubleArray, - jdouble*, jint); - - void (JNICALL *GetBooleanArrayRegion)(JNIEnv*, jbooleanArray, - jsize, jsize, jboolean*); - void (JNICALL *GetByteArrayRegion)(JNIEnv*, jbyteArray, - jsize, jsize, jbyte*); - void (JNICALL *GetCharArrayRegion)(JNIEnv*, jcharArray, - jsize, jsize, jchar*); - void (JNICALL *GetShortArrayRegion)(JNIEnv*, jshortArray, - jsize, jsize, jshort*); - void (JNICALL *GetIntArrayRegion)(JNIEnv*, jintArray, - jsize, jsize, jint*); - void (JNICALL *GetLongArrayRegion)(JNIEnv*, jlongArray, - jsize, jsize, jlong*); - void (JNICALL *GetFloatArrayRegion)(JNIEnv*, jfloatArray, - jsize, jsize, jfloat*); - void (JNICALL *GetDoubleArrayRegion)(JNIEnv*, jdoubleArray, - jsize, jsize, jdouble*); - - /* spec shows these without const; some jni.h do, some don't */ - void (JNICALL *SetBooleanArrayRegion)(JNIEnv*, jbooleanArray, - jsize, jsize, const jboolean*); - void (JNICALL *SetByteArrayRegion)(JNIEnv*, jbyteArray, - jsize, jsize, const jbyte*); - void (JNICALL *SetCharArrayRegion)(JNIEnv*, jcharArray, - jsize, jsize, const jchar*); - void (JNICALL *SetShortArrayRegion)(JNIEnv*, jshortArray, - jsize, jsize, const jshort*); - void (JNICALL *SetIntArrayRegion)(JNIEnv*, jintArray, - jsize, jsize, const jint*); - void (JNICALL *SetLongArrayRegion)(JNIEnv*, jlongArray, - jsize, jsize, const jlong*); - void (JNICALL *SetFloatArrayRegion)(JNIEnv*, jfloatArray, - jsize, jsize, const jfloat*); - void (JNICALL *SetDoubleArrayRegion)(JNIEnv*, jdoubleArray, - jsize, jsize, const jdouble*); - - jint (JNICALL *RegisterNatives)(JNIEnv*, jclass, const JNINativeMethod*, - jint); - jint (JNICALL *UnregisterNatives)(JNIEnv*, jclass); - jint (JNICALL *MonitorEnter)(JNIEnv*, jobject); - jint (JNICALL *MonitorExit)(JNIEnv*, jobject); - jint (JNICALL *GetJavaVM)(JNIEnv*, JavaVM**); - - void (JNICALL *GetStringRegion)(JNIEnv*, jstring, jsize, jsize, jchar*); - void (JNICALL *GetStringUTFRegion)(JNIEnv*, jstring, jsize, jsize, char*); - - void* (JNICALL *GetPrimitiveArrayCritical)(JNIEnv*, jarray, jboolean*); - void (JNICALL *ReleasePrimitiveArrayCritical)(JNIEnv*, jarray, void*, jint); - - const jchar* (JNICALL *GetStringCritical)(JNIEnv*, jstring, jboolean*); - void (JNICALL *ReleaseStringCritical)(JNIEnv*, jstring, const jchar*); - - jweak (JNICALL *NewWeakGlobalRef)(JNIEnv*, jobject); - void (JNICALL *DeleteWeakGlobalRef)(JNIEnv*, jweak); - - jboolean (JNICALL *ExceptionCheck)(JNIEnv*); - - jobject (JNICALL *NewDirectByteBuffer)(JNIEnv*, void*, jlong); - void* (JNICALL *GetDirectBufferAddress)(JNIEnv*, jobject); - jlong (JNICALL *GetDirectBufferCapacity)(JNIEnv*, jobject); - - /* added in JNI 1.6 */ - jobjectRefType (JNICALL *GetObjectRefType)(JNIEnv*, jobject); -}; - -/* - * C++ object wrapper. - * - * This is usually overlaid on a C struct whose first element is a - * JNINativeInterface*. We rely somewhat on compiler behavior. - */ -struct _JNIEnv { - /* do not rename this; it does not seem to be entirely opaque */ - const struct JNINativeInterface* functions; - -#if defined(__cplusplus) - - jint GetVersion() - { return functions->GetVersion(this); } - - jclass DefineClass(const char *name, jobject loader, const jbyte* buf, - jsize bufLen) - { return functions->DefineClass(this, name, loader, buf, bufLen); } - - jclass FindClass(const char* name) - { return functions->FindClass(this, name); } - - jmethodID FromReflectedMethod(jobject method) - { return functions->FromReflectedMethod(this, method); } - - jfieldID FromReflectedField(jobject field) - { return functions->FromReflectedField(this, field); } - - jobject ToReflectedMethod(jclass cls, jmethodID methodID, jboolean isStatic) - { return functions->ToReflectedMethod(this, cls, methodID, isStatic); } - - jclass GetSuperclass(jclass clazz) - { return functions->GetSuperclass(this, clazz); } - - jboolean IsAssignableFrom(jclass clazz1, jclass clazz2) - { return functions->IsAssignableFrom(this, clazz1, clazz2); } - - jobject ToReflectedField(jclass cls, jfieldID fieldID, jboolean isStatic) - { return functions->ToReflectedField(this, cls, fieldID, isStatic); } - - jint Throw(jthrowable obj) - { return functions->Throw(this, obj); } - - jint ThrowNew(jclass clazz, const char* message) - { return functions->ThrowNew(this, clazz, message); } - - jthrowable ExceptionOccurred() - { return functions->ExceptionOccurred(this); } - - void ExceptionDescribe() - { functions->ExceptionDescribe(this); } - - void ExceptionClear() - { functions->ExceptionClear(this); } - - void FatalError(const char* msg) - { functions->FatalError(this, msg); } - - jint PushLocalFrame(jint capacity) - { return functions->PushLocalFrame(this, capacity); } - - jobject PopLocalFrame(jobject result) - { return functions->PopLocalFrame(this, result); } - - jobject NewGlobalRef(jobject obj) - { return functions->NewGlobalRef(this, obj); } - - void DeleteGlobalRef(jobject globalRef) - { functions->DeleteGlobalRef(this, globalRef); } - - void DeleteLocalRef(jobject localRef) - { functions->DeleteLocalRef(this, localRef); } - - jboolean IsSameObject(jobject ref1, jobject ref2) - { return functions->IsSameObject(this, ref1, ref2); } - - jobject NewLocalRef(jobject ref) - { return functions->NewLocalRef(this, ref); } - - jint EnsureLocalCapacity(jint capacity) - { return functions->EnsureLocalCapacity(this, capacity); } - - jobject AllocObject(jclass clazz) - { return functions->AllocObject(this, clazz); } - - jobject NewObject(jclass clazz, jmethodID methodID, ...) - { - va_list args; - va_start(args, methodID); - jobject result = functions->NewObjectV(this, clazz, methodID, args); - va_end(args); - return result; - } - - jobject NewObjectV(jclass clazz, jmethodID methodID, va_list args) - { return functions->NewObjectV(this, clazz, methodID, args); } - - jobject NewObjectA(jclass clazz, jmethodID methodID, jvalue* args) - { return functions->NewObjectA(this, clazz, methodID, args); } - - jclass GetObjectClass(jobject obj) - { return functions->GetObjectClass(this, obj); } - - jboolean IsInstanceOf(jobject obj, jclass clazz) - { return functions->IsInstanceOf(this, obj, clazz); } - - jmethodID GetMethodID(jclass clazz, const char* name, const char* sig) - { return functions->GetMethodID(this, clazz, name, sig); } - -#define CALL_TYPE_METHOD(_jtype, _jname) \ - _jtype Call##_jname##Method(jobject obj, jmethodID methodID, ...) \ - { \ - _jtype result; \ - va_list args; \ - va_start(args, methodID); \ - result = functions->Call##_jname##MethodV(this, obj, methodID, \ - args); \ - va_end(args); \ - return result; \ - } -#define CALL_TYPE_METHODV(_jtype, _jname) \ - _jtype Call##_jname##MethodV(jobject obj, jmethodID methodID, \ - va_list args) \ - { return functions->Call##_jname##MethodV(this, obj, methodID, args); } -#define CALL_TYPE_METHODA(_jtype, _jname) \ - _jtype Call##_jname##MethodA(jobject obj, jmethodID methodID, \ - jvalue* args) \ - { return functions->Call##_jname##MethodA(this, obj, methodID, args); } - -#define CALL_TYPE(_jtype, _jname) \ - CALL_TYPE_METHOD(_jtype, _jname) \ - CALL_TYPE_METHODV(_jtype, _jname) \ - CALL_TYPE_METHODA(_jtype, _jname) - - CALL_TYPE(jobject, Object) - CALL_TYPE(jboolean, Boolean) - CALL_TYPE(jbyte, Byte) - CALL_TYPE(jchar, Char) - CALL_TYPE(jshort, Short) - CALL_TYPE(jint, Int) - CALL_TYPE(jlong, Long) - CALL_TYPE(jfloat, Float) - CALL_TYPE(jdouble, Double) - - void CallVoidMethod(jobject obj, jmethodID methodID, ...) - { - va_list args; - va_start(args, methodID); - functions->CallVoidMethodV(this, obj, methodID, args); - va_end(args); - } - void CallVoidMethodV(jobject obj, jmethodID methodID, va_list args) - { functions->CallVoidMethodV(this, obj, methodID, args); } - void CallVoidMethodA(jobject obj, jmethodID methodID, jvalue* args) - { functions->CallVoidMethodA(this, obj, methodID, args); } - -#define CALL_NONVIRT_TYPE_METHOD(_jtype, _jname) \ - _jtype CallNonvirtual##_jname##Method(jobject obj, jclass clazz, \ - jmethodID methodID, ...) \ - { \ - _jtype result; \ - va_list args; \ - va_start(args, methodID); \ - result = functions->CallNonvirtual##_jname##MethodV(this, obj, \ - clazz, methodID, args); \ - va_end(args); \ - return result; \ - } -#define CALL_NONVIRT_TYPE_METHODV(_jtype, _jname) \ - _jtype CallNonvirtual##_jname##MethodV(jobject obj, jclass clazz, \ - jmethodID methodID, va_list args) \ - { return functions->CallNonvirtual##_jname##MethodV(this, obj, clazz, \ - methodID, args); } -#define CALL_NONVIRT_TYPE_METHODA(_jtype, _jname) \ - _jtype CallNonvirtual##_jname##MethodA(jobject obj, jclass clazz, \ - jmethodID methodID, jvalue* args) \ - { return functions->CallNonvirtual##_jname##MethodA(this, obj, clazz, \ - methodID, args); } - -#define CALL_NONVIRT_TYPE(_jtype, _jname) \ - CALL_NONVIRT_TYPE_METHOD(_jtype, _jname) \ - CALL_NONVIRT_TYPE_METHODV(_jtype, _jname) \ - CALL_NONVIRT_TYPE_METHODA(_jtype, _jname) - - CALL_NONVIRT_TYPE(jobject, Object) - CALL_NONVIRT_TYPE(jboolean, Boolean) - CALL_NONVIRT_TYPE(jbyte, Byte) - CALL_NONVIRT_TYPE(jchar, Char) - CALL_NONVIRT_TYPE(jshort, Short) - CALL_NONVIRT_TYPE(jint, Int) - CALL_NONVIRT_TYPE(jlong, Long) - CALL_NONVIRT_TYPE(jfloat, Float) - CALL_NONVIRT_TYPE(jdouble, Double) - - void CallNonvirtualVoidMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) - { - va_list args; - va_start(args, methodID); - functions->CallNonvirtualVoidMethodV(this, obj, clazz, methodID, args); - va_end(args); - } - void CallNonvirtualVoidMethodV(jobject obj, jclass clazz, - jmethodID methodID, va_list args) - { functions->CallNonvirtualVoidMethodV(this, obj, clazz, methodID, args); } - void CallNonvirtualVoidMethodA(jobject obj, jclass clazz, - jmethodID methodID, jvalue* args) - { functions->CallNonvirtualVoidMethodA(this, obj, clazz, methodID, args); } - - jfieldID GetFieldID(jclass clazz, const char* name, const char* sig) - { return functions->GetFieldID(this, clazz, name, sig); } - - jobject GetObjectField(jobject obj, jfieldID fieldID) - { return functions->GetObjectField(this, obj, fieldID); } - jboolean GetBooleanField(jobject obj, jfieldID fieldID) - { return functions->GetBooleanField(this, obj, fieldID); } - jbyte GetByteField(jobject obj, jfieldID fieldID) - { return functions->GetByteField(this, obj, fieldID); } - jchar GetCharField(jobject obj, jfieldID fieldID) - { return functions->GetCharField(this, obj, fieldID); } - jshort GetShortField(jobject obj, jfieldID fieldID) - { return functions->GetShortField(this, obj, fieldID); } - jint GetIntField(jobject obj, jfieldID fieldID) - { return functions->GetIntField(this, obj, fieldID); } - jlong GetLongField(jobject obj, jfieldID fieldID) - { return functions->GetLongField(this, obj, fieldID); } - jfloat GetFloatField(jobject obj, jfieldID fieldID) - { return functions->GetFloatField(this, obj, fieldID); } - jdouble GetDoubleField(jobject obj, jfieldID fieldID) - { return functions->GetDoubleField(this, obj, fieldID); } - - void SetObjectField(jobject obj, jfieldID fieldID, jobject value) - { functions->SetObjectField(this, obj, fieldID, value); } - void SetBooleanField(jobject obj, jfieldID fieldID, jboolean value) - { functions->SetBooleanField(this, obj, fieldID, value); } - void SetByteField(jobject obj, jfieldID fieldID, jbyte value) - { functions->SetByteField(this, obj, fieldID, value); } - void SetCharField(jobject obj, jfieldID fieldID, jchar value) - { functions->SetCharField(this, obj, fieldID, value); } - void SetShortField(jobject obj, jfieldID fieldID, jshort value) - { functions->SetShortField(this, obj, fieldID, value); } - void SetIntField(jobject obj, jfieldID fieldID, jint value) - { functions->SetIntField(this, obj, fieldID, value); } - void SetLongField(jobject obj, jfieldID fieldID, jlong value) - { functions->SetLongField(this, obj, fieldID, value); } - void SetFloatField(jobject obj, jfieldID fieldID, jfloat value) - { functions->SetFloatField(this, obj, fieldID, value); } - void SetDoubleField(jobject obj, jfieldID fieldID, jdouble value) - { functions->SetDoubleField(this, obj, fieldID, value); } - - jmethodID GetStaticMethodID(jclass clazz, const char* name, const char* sig) - { return functions->GetStaticMethodID(this, clazz, name, sig); } - -#define CALL_STATIC_TYPE_METHOD(_jtype, _jname) \ - _jtype CallStatic##_jname##Method(jclass clazz, jmethodID methodID, \ - ...) \ - { \ - _jtype result; \ - va_list args; \ - va_start(args, methodID); \ - result = functions->CallStatic##_jname##MethodV(this, clazz, \ - methodID, args); \ - va_end(args); \ - return result; \ - } -#define CALL_STATIC_TYPE_METHODV(_jtype, _jname) \ - _jtype CallStatic##_jname##MethodV(jclass clazz, jmethodID methodID, \ - va_list args) \ - { return functions->CallStatic##_jname##MethodV(this, clazz, methodID, \ - args); } -#define CALL_STATIC_TYPE_METHODA(_jtype, _jname) \ - _jtype CallStatic##_jname##MethodA(jclass clazz, jmethodID methodID, \ - jvalue* args) \ - { return functions->CallStatic##_jname##MethodA(this, clazz, methodID, \ - args); } - -#define CALL_STATIC_TYPE(_jtype, _jname) \ - CALL_STATIC_TYPE_METHOD(_jtype, _jname) \ - CALL_STATIC_TYPE_METHODV(_jtype, _jname) \ - CALL_STATIC_TYPE_METHODA(_jtype, _jname) - - CALL_STATIC_TYPE(jobject, Object) - CALL_STATIC_TYPE(jboolean, Boolean) - CALL_STATIC_TYPE(jbyte, Byte) - CALL_STATIC_TYPE(jchar, Char) - CALL_STATIC_TYPE(jshort, Short) - CALL_STATIC_TYPE(jint, Int) - CALL_STATIC_TYPE(jlong, Long) - CALL_STATIC_TYPE(jfloat, Float) - CALL_STATIC_TYPE(jdouble, Double) - - void CallStaticVoidMethod(jclass clazz, jmethodID methodID, ...) - { - va_list args; - va_start(args, methodID); - functions->CallStaticVoidMethodV(this, clazz, methodID, args); - va_end(args); - } - void CallStaticVoidMethodV(jclass clazz, jmethodID methodID, va_list args) - { functions->CallStaticVoidMethodV(this, clazz, methodID, args); } - void CallStaticVoidMethodA(jclass clazz, jmethodID methodID, jvalue* args) - { functions->CallStaticVoidMethodA(this, clazz, methodID, args); } - - jfieldID GetStaticFieldID(jclass clazz, const char* name, const char* sig) - { return functions->GetStaticFieldID(this, clazz, name, sig); } - - jobject GetStaticObjectField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticObjectField(this, clazz, fieldID); } - jboolean GetStaticBooleanField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticBooleanField(this, clazz, fieldID); } - jbyte GetStaticByteField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticByteField(this, clazz, fieldID); } - jchar GetStaticCharField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticCharField(this, clazz, fieldID); } - jshort GetStaticShortField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticShortField(this, clazz, fieldID); } - jint GetStaticIntField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticIntField(this, clazz, fieldID); } - jlong GetStaticLongField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticLongField(this, clazz, fieldID); } - jfloat GetStaticFloatField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticFloatField(this, clazz, fieldID); } - jdouble GetStaticDoubleField(jclass clazz, jfieldID fieldID) - { return functions->GetStaticDoubleField(this, clazz, fieldID); } - - void SetStaticObjectField(jclass clazz, jfieldID fieldID, jobject value) - { functions->SetStaticObjectField(this, clazz, fieldID, value); } - void SetStaticBooleanField(jclass clazz, jfieldID fieldID, jboolean value) - { functions->SetStaticBooleanField(this, clazz, fieldID, value); } - void SetStaticByteField(jclass clazz, jfieldID fieldID, jbyte value) - { functions->SetStaticByteField(this, clazz, fieldID, value); } - void SetStaticCharField(jclass clazz, jfieldID fieldID, jchar value) - { functions->SetStaticCharField(this, clazz, fieldID, value); } - void SetStaticShortField(jclass clazz, jfieldID fieldID, jshort value) - { functions->SetStaticShortField(this, clazz, fieldID, value); } - void SetStaticIntField(jclass clazz, jfieldID fieldID, jint value) - { functions->SetStaticIntField(this, clazz, fieldID, value); } - void SetStaticLongField(jclass clazz, jfieldID fieldID, jlong value) - { functions->SetStaticLongField(this, clazz, fieldID, value); } - void SetStaticFloatField(jclass clazz, jfieldID fieldID, jfloat value) - { functions->SetStaticFloatField(this, clazz, fieldID, value); } - void SetStaticDoubleField(jclass clazz, jfieldID fieldID, jdouble value) - { functions->SetStaticDoubleField(this, clazz, fieldID, value); } - - jstring NewString(const jchar* unicodeChars, jsize len) - { return functions->NewString(this, unicodeChars, len); } - - jsize GetStringLength(jstring string) - { return functions->GetStringLength(this, string); } - - const jchar* GetStringChars(jstring string, jboolean* isCopy) - { return functions->GetStringChars(this, string, isCopy); } - - void ReleaseStringChars(jstring string, const jchar* chars) - { functions->ReleaseStringChars(this, string, chars); } - - jstring NewStringUTF(const char* bytes) - { return functions->NewStringUTF(this, bytes); } - - jsize GetStringUTFLength(jstring string) - { return functions->GetStringUTFLength(this, string); } - - const char* GetStringUTFChars(jstring string, jboolean* isCopy) - { return functions->GetStringUTFChars(this, string, isCopy); } - - void ReleaseStringUTFChars(jstring string, const char* utf) - { functions->ReleaseStringUTFChars(this, string, utf); } - - jsize GetArrayLength(jarray array) - { return functions->GetArrayLength(this, array); } - - jobjectArray NewObjectArray(jsize length, jclass elementClass, - jobject initialElement) - { return functions->NewObjectArray(this, length, elementClass, - initialElement); } - - jobject GetObjectArrayElement(jobjectArray array, jsize index) - { return functions->GetObjectArrayElement(this, array, index); } - - void SetObjectArrayElement(jobjectArray array, jsize index, jobject value) - { functions->SetObjectArrayElement(this, array, index, value); } - - jbooleanArray NewBooleanArray(jsize length) - { return functions->NewBooleanArray(this, length); } - jbyteArray NewByteArray(jsize length) - { return functions->NewByteArray(this, length); } - jcharArray NewCharArray(jsize length) - { return functions->NewCharArray(this, length); } - jshortArray NewShortArray(jsize length) - { return functions->NewShortArray(this, length); } - jintArray NewIntArray(jsize length) - { return functions->NewIntArray(this, length); } - jlongArray NewLongArray(jsize length) - { return functions->NewLongArray(this, length); } - jfloatArray NewFloatArray(jsize length) - { return functions->NewFloatArray(this, length); } - jdoubleArray NewDoubleArray(jsize length) - { return functions->NewDoubleArray(this, length); } - - jboolean* GetBooleanArrayElements(jbooleanArray array, jboolean* isCopy) - { return functions->GetBooleanArrayElements(this, array, isCopy); } - jbyte* GetByteArrayElements(jbyteArray array, jboolean* isCopy) - { return functions->GetByteArrayElements(this, array, isCopy); } - jchar* GetCharArrayElements(jcharArray array, jboolean* isCopy) - { return functions->GetCharArrayElements(this, array, isCopy); } - jshort* GetShortArrayElements(jshortArray array, jboolean* isCopy) - { return functions->GetShortArrayElements(this, array, isCopy); } - jint* GetIntArrayElements(jintArray array, jboolean* isCopy) - { return functions->GetIntArrayElements(this, array, isCopy); } - jlong* GetLongArrayElements(jlongArray array, jboolean* isCopy) - { return functions->GetLongArrayElements(this, array, isCopy); } - jfloat* GetFloatArrayElements(jfloatArray array, jboolean* isCopy) - { return functions->GetFloatArrayElements(this, array, isCopy); } - jdouble* GetDoubleArrayElements(jdoubleArray array, jboolean* isCopy) - { return functions->GetDoubleArrayElements(this, array, isCopy); } - - void ReleaseBooleanArrayElements(jbooleanArray array, jboolean* elems, - jint mode) - { functions->ReleaseBooleanArrayElements(this, array, elems, mode); } - void ReleaseByteArrayElements(jbyteArray array, jbyte* elems, - jint mode) - { functions->ReleaseByteArrayElements(this, array, elems, mode); } - void ReleaseCharArrayElements(jcharArray array, jchar* elems, - jint mode) - { functions->ReleaseCharArrayElements(this, array, elems, mode); } - void ReleaseShortArrayElements(jshortArray array, jshort* elems, - jint mode) - { functions->ReleaseShortArrayElements(this, array, elems, mode); } - void ReleaseIntArrayElements(jintArray array, jint* elems, - jint mode) - { functions->ReleaseIntArrayElements(this, array, elems, mode); } - void ReleaseLongArrayElements(jlongArray array, jlong* elems, - jint mode) - { functions->ReleaseLongArrayElements(this, array, elems, mode); } - void ReleaseFloatArrayElements(jfloatArray array, jfloat* elems, - jint mode) - { functions->ReleaseFloatArrayElements(this, array, elems, mode); } - void ReleaseDoubleArrayElements(jdoubleArray array, jdouble* elems, - jint mode) - { functions->ReleaseDoubleArrayElements(this, array, elems, mode); } - - void GetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len, - jboolean* buf) - { functions->GetBooleanArrayRegion(this, array, start, len, buf); } - void GetByteArrayRegion(jbyteArray array, jsize start, jsize len, - jbyte* buf) - { functions->GetByteArrayRegion(this, array, start, len, buf); } - void GetCharArrayRegion(jcharArray array, jsize start, jsize len, - jchar* buf) - { functions->GetCharArrayRegion(this, array, start, len, buf); } - void GetShortArrayRegion(jshortArray array, jsize start, jsize len, - jshort* buf) - { functions->GetShortArrayRegion(this, array, start, len, buf); } - void GetIntArrayRegion(jintArray array, jsize start, jsize len, - jint* buf) - { functions->GetIntArrayRegion(this, array, start, len, buf); } - void GetLongArrayRegion(jlongArray array, jsize start, jsize len, - jlong* buf) - { functions->GetLongArrayRegion(this, array, start, len, buf); } - void GetFloatArrayRegion(jfloatArray array, jsize start, jsize len, - jfloat* buf) - { functions->GetFloatArrayRegion(this, array, start, len, buf); } - void GetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, - jdouble* buf) - { functions->GetDoubleArrayRegion(this, array, start, len, buf); } - - void SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len, - const jboolean* buf) - { functions->SetBooleanArrayRegion(this, array, start, len, buf); } - void SetByteArrayRegion(jbyteArray array, jsize start, jsize len, - const jbyte* buf) - { functions->SetByteArrayRegion(this, array, start, len, buf); } - void SetCharArrayRegion(jcharArray array, jsize start, jsize len, - const jchar* buf) - { functions->SetCharArrayRegion(this, array, start, len, buf); } - void SetShortArrayRegion(jshortArray array, jsize start, jsize len, - const jshort* buf) - { functions->SetShortArrayRegion(this, array, start, len, buf); } - void SetIntArrayRegion(jintArray array, jsize start, jsize len, - const jint* buf) - { functions->SetIntArrayRegion(this, array, start, len, buf); } - void SetLongArrayRegion(jlongArray array, jsize start, jsize len, - const jlong* buf) - { functions->SetLongArrayRegion(this, array, start, len, buf); } - void SetFloatArrayRegion(jfloatArray array, jsize start, jsize len, - const jfloat* buf) - { functions->SetFloatArrayRegion(this, array, start, len, buf); } - void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, - const jdouble* buf) - { functions->SetDoubleArrayRegion(this, array, start, len, buf); } - - jint RegisterNatives(jclass clazz, const JNINativeMethod* methods, - jint nMethods) - { return functions->RegisterNatives(this, clazz, methods, nMethods); } - - jint UnregisterNatives(jclass clazz) - { return functions->UnregisterNatives(this, clazz); } - - jint MonitorEnter(jobject obj) - { return functions->MonitorEnter(this, obj); } - - jint MonitorExit(jobject obj) - { return functions->MonitorExit(this, obj); } - - jint GetJavaVM(JavaVM** vm) - { return functions->GetJavaVM(this, vm); } - - void GetStringRegion(jstring str, jsize start, jsize len, jchar* buf) - { functions->GetStringRegion(this, str, start, len, buf); } - - void GetStringUTFRegion(jstring str, jsize start, jsize len, char* buf) - { return functions->GetStringUTFRegion(this, str, start, len, buf); } - - void* GetPrimitiveArrayCritical(jarray array, jboolean* isCopy) - { return functions->GetPrimitiveArrayCritical(this, array, isCopy); } - - void ReleasePrimitiveArrayCritical(jarray array, void* carray, jint mode) - { functions->ReleasePrimitiveArrayCritical(this, array, carray, mode); } - - const jchar* GetStringCritical(jstring string, jboolean* isCopy) - { return functions->GetStringCritical(this, string, isCopy); } - - void ReleaseStringCritical(jstring string, const jchar* carray) - { functions->ReleaseStringCritical(this, string, carray); } - - jweak NewWeakGlobalRef(jobject obj) - { return functions->NewWeakGlobalRef(this, obj); } - - void DeleteWeakGlobalRef(jweak obj) - { functions->DeleteWeakGlobalRef(this, obj); } - - jboolean ExceptionCheck() - { return functions->ExceptionCheck(this); } - - jobject NewDirectByteBuffer(void* address, jlong capacity) - { return functions->NewDirectByteBuffer(this, address, capacity); } - - void* GetDirectBufferAddress(jobject buf) - { return functions->GetDirectBufferAddress(this, buf); } - - jlong GetDirectBufferCapacity(jobject buf) - { return functions->GetDirectBufferCapacity(this, buf); } - - /* added in JNI 1.6 */ - jobjectRefType GetObjectRefType(jobject obj) - { return functions->GetObjectRefType(this, obj); } -#endif /*__cplusplus*/ -}; - - -/* - * JNI invocation interface. - */ -struct JNIInvokeInterface { - void* reserved0; - void* reserved1; - void* reserved2; - - jint (JNICALL *DestroyJavaVM)(JavaVM*); - jint (JNICALL *AttachCurrentThread)(JavaVM*, JNIEnv**, void*); - jint (JNICALL *DetachCurrentThread)(JavaVM*); - jint (JNICALL *GetEnv)(JavaVM*, void**, jint); - jint (JNICALL *AttachCurrentThreadAsDaemon)(JavaVM*, JNIEnv**, void*); -}; - -/* - * C++ version. - */ -struct _JavaVM { - const struct JNIInvokeInterface* functions; - -#if defined(__cplusplus) - jint DestroyJavaVM() - { return functions->DestroyJavaVM(this); } - jint AttachCurrentThread(JNIEnv** p_env, void* thr_args) - { return functions->AttachCurrentThread(this, p_env, thr_args); } - jint DetachCurrentThread() - { return functions->DetachCurrentThread(this); } - jint GetEnv(void** env, jint version) - { return functions->GetEnv(this, env, version); } - jint AttachCurrentThreadAsDaemon(JNIEnv** p_env, void* thr_args) - { return functions->AttachCurrentThreadAsDaemon(this, p_env, thr_args); } -#endif /*__cplusplus*/ -}; - -struct JavaVMAttachArgs { - jint version; /* must be >= JNI_VERSION_1_2 */ - const char* name; /* NULL or name of thread as modified UTF-8 str */ - jobject group; /* global ref of a ThreadGroup object, or NULL */ -}; -typedef struct JavaVMAttachArgs JavaVMAttachArgs; - -/* - * JNI 1.2+ initialization. (As of 1.6, the pre-1.2 structures are no - * longer supported.) - */ -typedef struct JavaVMOption { - const char* optionString; - void* extraInfo; -} JavaVMOption; - -typedef struct JavaVMInitArgs { - jint version; /* use JNI_VERSION_1_2 or later */ - - jint nOptions; - JavaVMOption* options; - jboolean ignoreUnrecognized; -} JavaVMInitArgs; - -#ifdef __cplusplus -extern "C" { -#endif -/* - * VM initialization functions. - * - * Note these are the only symbols exported for JNI by the VM. - */ -#if 0 /* In practice, these are not exported by the NDK so don't declare them */ -jint JNI_GetDefaultJavaVMInitArgs(void*); -jint JNI_CreateJavaVM(JavaVM**, JNIEnv**, void*); -jint JNI_GetCreatedJavaVMs(JavaVM**, jsize, jsize*); -#endif - -/* - * Prototypes for functions exported by loadable shared libs. These are - * called by JNI, not provided by JNI. - */ -JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved); -JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved); - -#ifdef __cplusplus -} -#endif - - -/* - * Manifest constants. - */ -#define JNI_FALSE 0 -#define JNI_TRUE 1 - -#define JNI_VERSION_1_1 0x00010001 -#define JNI_VERSION_1_2 0x00010002 -#define JNI_VERSION_1_4 0x00010004 -#define JNI_VERSION_1_6 0x00010006 - -#define JNI_OK (0) /* no error */ -#define JNI_ERR (-1) /* generic error */ -#define JNI_EDETACHED (-2) /* thread detached from the VM */ -#define JNI_EVERSION (-3) /* JNI version error */ - -#define JNI_COMMIT 1 /* copy content, do not free buffer */ -#define JNI_ABORT 2 /* free buffer w/o copying back */ - -#endif /* JNI_H_ */ diff --git a/chrome/test/chromedriver/third_party/jni/patch.diff b/chrome/test/chromedriver/third_party/jni/patch.diff deleted file mode 100644 index 8e1d1f8483..0000000000 --- a/chrome/test/chromedriver/third_party/jni/patch.diff +++ /dev/null @@ -1,631 +0,0 @@ -Index: chrome/test/chromedriver/third_party/jni/jni.h -diff --git a/chrome/test/chromedriver/third_party/jni/jni.h b/chrome/test/chromedriver/third_party/jni/jni.h -index 495902c..2c44f07 100644 ---- a/chrome/test/chromedriver/third_party/jni/jni.h -+++ b/chrome/test/chromedriver/third_party/jni/jni.h -@@ -26,6 +26,16 @@ - - #include <stdarg.h> - -+#ifdef _WIN32 -+#define JNIIMPORT __declspec(dllimport) -+#define JNIEXPORT __declspec(dllexport) -+#define JNICALL __stdcall -+#else -+#define JNIIMPORT -+#define JNIEXPORT __attribute__ ((visibility ("default"))) -+#define JNICALL -+#endif -+ - /* - * Primitive types that match up with Java equivalents. - */ -@@ -166,333 +176,333 @@ struct JNINativeInterface { - void* reserved2; - void* reserved3; - -- jint (*GetVersion)(JNIEnv *); -+ jint (JNICALL *GetVersion)(JNIEnv *); - -- jclass (*DefineClass)(JNIEnv*, const char*, jobject, const jbyte*, -+ jclass (JNICALL *DefineClass)(JNIEnv*, const char*, jobject, const jbyte*, - jsize); -- jclass (*FindClass)(JNIEnv*, const char*); -+ jclass (JNICALL *FindClass)(JNIEnv*, const char*); - -- jmethodID (*FromReflectedMethod)(JNIEnv*, jobject); -- jfieldID (*FromReflectedField)(JNIEnv*, jobject); -+ jmethodID (JNICALL *FromReflectedMethod)(JNIEnv*, jobject); -+ jfieldID (JNICALL *FromReflectedField)(JNIEnv*, jobject); - /* spec doesn't show jboolean parameter */ -- jobject (*ToReflectedMethod)(JNIEnv*, jclass, jmethodID, jboolean); -+ jobject (JNICALL *ToReflectedMethod)(JNIEnv*, jclass, jmethodID, jboolean); - -- jclass (*GetSuperclass)(JNIEnv*, jclass); -- jboolean (*IsAssignableFrom)(JNIEnv*, jclass, jclass); -+ jclass (JNICALL *GetSuperclass)(JNIEnv*, jclass); -+ jboolean (JNICALL *IsAssignableFrom)(JNIEnv*, jclass, jclass); - - /* spec doesn't show jboolean parameter */ -- jobject (*ToReflectedField)(JNIEnv*, jclass, jfieldID, jboolean); -- -- jint (*Throw)(JNIEnv*, jthrowable); -- jint (*ThrowNew)(JNIEnv *, jclass, const char *); -- jthrowable (*ExceptionOccurred)(JNIEnv*); -- void (*ExceptionDescribe)(JNIEnv*); -- void (*ExceptionClear)(JNIEnv*); -- void (*FatalError)(JNIEnv*, const char*); -- -- jint (*PushLocalFrame)(JNIEnv*, jint); -- jobject (*PopLocalFrame)(JNIEnv*, jobject); -- -- jobject (*NewGlobalRef)(JNIEnv*, jobject); -- void (*DeleteGlobalRef)(JNIEnv*, jobject); -- void (*DeleteLocalRef)(JNIEnv*, jobject); -- jboolean (*IsSameObject)(JNIEnv*, jobject, jobject); -- -- jobject (*NewLocalRef)(JNIEnv*, jobject); -- jint (*EnsureLocalCapacity)(JNIEnv*, jint); -- -- jobject (*AllocObject)(JNIEnv*, jclass); -- jobject (*NewObject)(JNIEnv*, jclass, jmethodID, ...); -- jobject (*NewObjectV)(JNIEnv*, jclass, jmethodID, va_list); -- jobject (*NewObjectA)(JNIEnv*, jclass, jmethodID, jvalue*); -- -- jclass (*GetObjectClass)(JNIEnv*, jobject); -- jboolean (*IsInstanceOf)(JNIEnv*, jobject, jclass); -- jmethodID (*GetMethodID)(JNIEnv*, jclass, const char*, const char*); -- -- jobject (*CallObjectMethod)(JNIEnv*, jobject, jmethodID, ...); -- jobject (*CallObjectMethodV)(JNIEnv*, jobject, jmethodID, va_list); -- jobject (*CallObjectMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -- jboolean (*CallBooleanMethod)(JNIEnv*, jobject, jmethodID, ...); -- jboolean (*CallBooleanMethodV)(JNIEnv*, jobject, jmethodID, va_list); -- jboolean (*CallBooleanMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -- jbyte (*CallByteMethod)(JNIEnv*, jobject, jmethodID, ...); -- jbyte (*CallByteMethodV)(JNIEnv*, jobject, jmethodID, va_list); -- jbyte (*CallByteMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -- jchar (*CallCharMethod)(JNIEnv*, jobject, jmethodID, ...); -- jchar (*CallCharMethodV)(JNIEnv*, jobject, jmethodID, va_list); -- jchar (*CallCharMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -- jshort (*CallShortMethod)(JNIEnv*, jobject, jmethodID, ...); -- jshort (*CallShortMethodV)(JNIEnv*, jobject, jmethodID, va_list); -- jshort (*CallShortMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -- jint (*CallIntMethod)(JNIEnv*, jobject, jmethodID, ...); -- jint (*CallIntMethodV)(JNIEnv*, jobject, jmethodID, va_list); -- jint (*CallIntMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -- jlong (*CallLongMethod)(JNIEnv*, jobject, jmethodID, ...); -- jlong (*CallLongMethodV)(JNIEnv*, jobject, jmethodID, va_list); -- jlong (*CallLongMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -- jfloat (*CallFloatMethod)(JNIEnv*, jobject, jmethodID, ...); -- jfloat (*CallFloatMethodV)(JNIEnv*, jobject, jmethodID, va_list); -- jfloat (*CallFloatMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -- jdouble (*CallDoubleMethod)(JNIEnv*, jobject, jmethodID, ...); -- jdouble (*CallDoubleMethodV)(JNIEnv*, jobject, jmethodID, va_list); -- jdouble (*CallDoubleMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -- void (*CallVoidMethod)(JNIEnv*, jobject, jmethodID, ...); -- void (*CallVoidMethodV)(JNIEnv*, jobject, jmethodID, va_list); -- void (*CallVoidMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -- -- jobject (*CallNonvirtualObjectMethod)(JNIEnv*, jobject, jclass, -+ jobject (JNICALL *ToReflectedField)(JNIEnv*, jclass, jfieldID, jboolean); -+ -+ jint (JNICALL *Throw)(JNIEnv*, jthrowable); -+ jint (JNICALL *ThrowNew)(JNIEnv *, jclass, const char *); -+ jthrowable (JNICALL *ExceptionOccurred)(JNIEnv*); -+ void (JNICALL *ExceptionDescribe)(JNIEnv*); -+ void (JNICALL *ExceptionClear)(JNIEnv*); -+ void (JNICALL *FatalError)(JNIEnv*, const char*); -+ -+ jint (JNICALL *PushLocalFrame)(JNIEnv*, jint); -+ jobject (JNICALL *PopLocalFrame)(JNIEnv*, jobject); -+ -+ jobject (JNICALL *NewGlobalRef)(JNIEnv*, jobject); -+ void (JNICALL *DeleteGlobalRef)(JNIEnv*, jobject); -+ void (JNICALL *DeleteLocalRef)(JNIEnv*, jobject); -+ jboolean (JNICALL *IsSameObject)(JNIEnv*, jobject, jobject); -+ -+ jobject (JNICALL *NewLocalRef)(JNIEnv*, jobject); -+ jint (JNICALL *EnsureLocalCapacity)(JNIEnv*, jint); -+ -+ jobject (JNICALL *AllocObject)(JNIEnv*, jclass); -+ jobject (JNICALL *NewObject)(JNIEnv*, jclass, jmethodID, ...); -+ jobject (JNICALL *NewObjectV)(JNIEnv*, jclass, jmethodID, va_list); -+ jobject (JNICALL *NewObjectA)(JNIEnv*, jclass, jmethodID, jvalue*); -+ -+ jclass (JNICALL *GetObjectClass)(JNIEnv*, jobject); -+ jboolean (JNICALL *IsInstanceOf)(JNIEnv*, jobject, jclass); -+ jmethodID (JNICALL *GetMethodID)(JNIEnv*, jclass, const char*, const char*); -+ -+ jobject (JNICALL *CallObjectMethod)(JNIEnv*, jobject, jmethodID, ...); -+ jobject (JNICALL *CallObjectMethodV)(JNIEnv*, jobject, jmethodID, va_list); -+ jobject (JNICALL *CallObjectMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -+ jboolean (JNICALL *CallBooleanMethod)(JNIEnv*, jobject, jmethodID, ...); -+ jboolean (JNICALL *CallBooleanMethodV)(JNIEnv*, jobject, jmethodID, va_list); -+ jboolean (JNICALL *CallBooleanMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -+ jbyte (JNICALL *CallByteMethod)(JNIEnv*, jobject, jmethodID, ...); -+ jbyte (JNICALL *CallByteMethodV)(JNIEnv*, jobject, jmethodID, va_list); -+ jbyte (JNICALL *CallByteMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -+ jchar (JNICALL *CallCharMethod)(JNIEnv*, jobject, jmethodID, ...); -+ jchar (JNICALL *CallCharMethodV)(JNIEnv*, jobject, jmethodID, va_list); -+ jchar (JNICALL *CallCharMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -+ jshort (JNICALL *CallShortMethod)(JNIEnv*, jobject, jmethodID, ...); -+ jshort (JNICALL *CallShortMethodV)(JNIEnv*, jobject, jmethodID, va_list); -+ jshort (JNICALL *CallShortMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -+ jint (JNICALL *CallIntMethod)(JNIEnv*, jobject, jmethodID, ...); -+ jint (JNICALL *CallIntMethodV)(JNIEnv*, jobject, jmethodID, va_list); -+ jint (JNICALL *CallIntMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -+ jlong (JNICALL *CallLongMethod)(JNIEnv*, jobject, jmethodID, ...); -+ jlong (JNICALL *CallLongMethodV)(JNIEnv*, jobject, jmethodID, va_list); -+ jlong (JNICALL *CallLongMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -+ jfloat (JNICALL *CallFloatMethod)(JNIEnv*, jobject, jmethodID, ...); -+ jfloat (JNICALL *CallFloatMethodV)(JNIEnv*, jobject, jmethodID, va_list); -+ jfloat (JNICALL *CallFloatMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -+ jdouble (JNICALL *CallDoubleMethod)(JNIEnv*, jobject, jmethodID, ...); -+ jdouble (JNICALL *CallDoubleMethodV)(JNIEnv*, jobject, jmethodID, va_list); -+ jdouble (JNICALL *CallDoubleMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -+ void (JNICALL *CallVoidMethod)(JNIEnv*, jobject, jmethodID, ...); -+ void (JNICALL *CallVoidMethodV)(JNIEnv*, jobject, jmethodID, va_list); -+ void (JNICALL *CallVoidMethodA)(JNIEnv*, jobject, jmethodID, jvalue*); -+ -+ jobject (JNICALL *CallNonvirtualObjectMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); -- jobject (*CallNonvirtualObjectMethodV)(JNIEnv*, jobject, jclass, -+ jobject (JNICALL *CallNonvirtualObjectMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); -- jobject (*CallNonvirtualObjectMethodA)(JNIEnv*, jobject, jclass, -+ jobject (JNICALL *CallNonvirtualObjectMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); -- jboolean (*CallNonvirtualBooleanMethod)(JNIEnv*, jobject, jclass, -+ jboolean (JNICALL *CallNonvirtualBooleanMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); -- jboolean (*CallNonvirtualBooleanMethodV)(JNIEnv*, jobject, jclass, -+ jboolean (JNICALL *CallNonvirtualBooleanMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); -- jboolean (*CallNonvirtualBooleanMethodA)(JNIEnv*, jobject, jclass, -+ jboolean (JNICALL *CallNonvirtualBooleanMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); -- jbyte (*CallNonvirtualByteMethod)(JNIEnv*, jobject, jclass, -+ jbyte (JNICALL *CallNonvirtualByteMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); -- jbyte (*CallNonvirtualByteMethodV)(JNIEnv*, jobject, jclass, -+ jbyte (JNICALL *CallNonvirtualByteMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); -- jbyte (*CallNonvirtualByteMethodA)(JNIEnv*, jobject, jclass, -+ jbyte (JNICALL *CallNonvirtualByteMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); -- jchar (*CallNonvirtualCharMethod)(JNIEnv*, jobject, jclass, -+ jchar (JNICALL *CallNonvirtualCharMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); -- jchar (*CallNonvirtualCharMethodV)(JNIEnv*, jobject, jclass, -+ jchar (JNICALL *CallNonvirtualCharMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); -- jchar (*CallNonvirtualCharMethodA)(JNIEnv*, jobject, jclass, -+ jchar (JNICALL *CallNonvirtualCharMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); -- jshort (*CallNonvirtualShortMethod)(JNIEnv*, jobject, jclass, -+ jshort (JNICALL *CallNonvirtualShortMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); -- jshort (*CallNonvirtualShortMethodV)(JNIEnv*, jobject, jclass, -+ jshort (JNICALL *CallNonvirtualShortMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); -- jshort (*CallNonvirtualShortMethodA)(JNIEnv*, jobject, jclass, -+ jshort (JNICALL *CallNonvirtualShortMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); -- jint (*CallNonvirtualIntMethod)(JNIEnv*, jobject, jclass, -+ jint (JNICALL *CallNonvirtualIntMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); -- jint (*CallNonvirtualIntMethodV)(JNIEnv*, jobject, jclass, -+ jint (JNICALL *CallNonvirtualIntMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); -- jint (*CallNonvirtualIntMethodA)(JNIEnv*, jobject, jclass, -+ jint (JNICALL *CallNonvirtualIntMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); -- jlong (*CallNonvirtualLongMethod)(JNIEnv*, jobject, jclass, -+ jlong (JNICALL *CallNonvirtualLongMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); -- jlong (*CallNonvirtualLongMethodV)(JNIEnv*, jobject, jclass, -+ jlong (JNICALL *CallNonvirtualLongMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); -- jlong (*CallNonvirtualLongMethodA)(JNIEnv*, jobject, jclass, -+ jlong (JNICALL *CallNonvirtualLongMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); -- jfloat (*CallNonvirtualFloatMethod)(JNIEnv*, jobject, jclass, -+ jfloat (JNICALL *CallNonvirtualFloatMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); -- jfloat (*CallNonvirtualFloatMethodV)(JNIEnv*, jobject, jclass, -+ jfloat (JNICALL *CallNonvirtualFloatMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); -- jfloat (*CallNonvirtualFloatMethodA)(JNIEnv*, jobject, jclass, -+ jfloat (JNICALL *CallNonvirtualFloatMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); -- jdouble (*CallNonvirtualDoubleMethod)(JNIEnv*, jobject, jclass, -+ jdouble (JNICALL *CallNonvirtualDoubleMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); -- jdouble (*CallNonvirtualDoubleMethodV)(JNIEnv*, jobject, jclass, -+ jdouble (JNICALL *CallNonvirtualDoubleMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); -- jdouble (*CallNonvirtualDoubleMethodA)(JNIEnv*, jobject, jclass, -+ jdouble (JNICALL *CallNonvirtualDoubleMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); -- void (*CallNonvirtualVoidMethod)(JNIEnv*, jobject, jclass, -+ void (JNICALL *CallNonvirtualVoidMethod)(JNIEnv*, jobject, jclass, - jmethodID, ...); -- void (*CallNonvirtualVoidMethodV)(JNIEnv*, jobject, jclass, -+ void (JNICALL *CallNonvirtualVoidMethodV)(JNIEnv*, jobject, jclass, - jmethodID, va_list); -- void (*CallNonvirtualVoidMethodA)(JNIEnv*, jobject, jclass, -+ void (JNICALL *CallNonvirtualVoidMethodA)(JNIEnv*, jobject, jclass, - jmethodID, jvalue*); - -- jfieldID (*GetFieldID)(JNIEnv*, jclass, const char*, const char*); -- -- jobject (*GetObjectField)(JNIEnv*, jobject, jfieldID); -- jboolean (*GetBooleanField)(JNIEnv*, jobject, jfieldID); -- jbyte (*GetByteField)(JNIEnv*, jobject, jfieldID); -- jchar (*GetCharField)(JNIEnv*, jobject, jfieldID); -- jshort (*GetShortField)(JNIEnv*, jobject, jfieldID); -- jint (*GetIntField)(JNIEnv*, jobject, jfieldID); -- jlong (*GetLongField)(JNIEnv*, jobject, jfieldID); -- jfloat (*GetFloatField)(JNIEnv*, jobject, jfieldID); -- jdouble (*GetDoubleField)(JNIEnv*, jobject, jfieldID); -- -- void (*SetObjectField)(JNIEnv*, jobject, jfieldID, jobject); -- void (*SetBooleanField)(JNIEnv*, jobject, jfieldID, jboolean); -- void (*SetByteField)(JNIEnv*, jobject, jfieldID, jbyte); -- void (*SetCharField)(JNIEnv*, jobject, jfieldID, jchar); -- void (*SetShortField)(JNIEnv*, jobject, jfieldID, jshort); -- void (*SetIntField)(JNIEnv*, jobject, jfieldID, jint); -- void (*SetLongField)(JNIEnv*, jobject, jfieldID, jlong); -- void (*SetFloatField)(JNIEnv*, jobject, jfieldID, jfloat); -- void (*SetDoubleField)(JNIEnv*, jobject, jfieldID, jdouble); -- -- jmethodID (*GetStaticMethodID)(JNIEnv*, jclass, const char*, const char*); -- -- jobject (*CallStaticObjectMethod)(JNIEnv*, jclass, jmethodID, ...); -- jobject (*CallStaticObjectMethodV)(JNIEnv*, jclass, jmethodID, va_list); -- jobject (*CallStaticObjectMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -- jboolean (*CallStaticBooleanMethod)(JNIEnv*, jclass, jmethodID, ...); -- jboolean (*CallStaticBooleanMethodV)(JNIEnv*, jclass, jmethodID, -+ jfieldID (JNICALL *GetFieldID)(JNIEnv*, jclass, const char*, const char*); -+ -+ jobject (JNICALL *GetObjectField)(JNIEnv*, jobject, jfieldID); -+ jboolean (JNICALL *GetBooleanField)(JNIEnv*, jobject, jfieldID); -+ jbyte (JNICALL *GetByteField)(JNIEnv*, jobject, jfieldID); -+ jchar (JNICALL *GetCharField)(JNIEnv*, jobject, jfieldID); -+ jshort (JNICALL *GetShortField)(JNIEnv*, jobject, jfieldID); -+ jint (JNICALL *GetIntField)(JNIEnv*, jobject, jfieldID); -+ jlong (JNICALL *GetLongField)(JNIEnv*, jobject, jfieldID); -+ jfloat (JNICALL *GetFloatField)(JNIEnv*, jobject, jfieldID); -+ jdouble (JNICALL *GetDoubleField)(JNIEnv*, jobject, jfieldID); -+ -+ void (JNICALL *SetObjectField)(JNIEnv*, jobject, jfieldID, jobject); -+ void (JNICALL *SetBooleanField)(JNIEnv*, jobject, jfieldID, jboolean); -+ void (JNICALL *SetByteField)(JNIEnv*, jobject, jfieldID, jbyte); -+ void (JNICALL *SetCharField)(JNIEnv*, jobject, jfieldID, jchar); -+ void (JNICALL *SetShortField)(JNIEnv*, jobject, jfieldID, jshort); -+ void (JNICALL *SetIntField)(JNIEnv*, jobject, jfieldID, jint); -+ void (JNICALL *SetLongField)(JNIEnv*, jobject, jfieldID, jlong); -+ void (JNICALL *SetFloatField)(JNIEnv*, jobject, jfieldID, jfloat); -+ void (JNICALL *SetDoubleField)(JNIEnv*, jobject, jfieldID, jdouble); -+ -+ jmethodID (JNICALL *GetStaticMethodID)(JNIEnv*, jclass, const char*, const char*); -+ -+ jobject (JNICALL *CallStaticObjectMethod)(JNIEnv*, jclass, jmethodID, ...); -+ jobject (JNICALL *CallStaticObjectMethodV)(JNIEnv*, jclass, jmethodID, va_list); -+ jobject (JNICALL *CallStaticObjectMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -+ jboolean (JNICALL *CallStaticBooleanMethod)(JNIEnv*, jclass, jmethodID, ...); -+ jboolean (JNICALL *CallStaticBooleanMethodV)(JNIEnv*, jclass, jmethodID, - va_list); -- jboolean (*CallStaticBooleanMethodA)(JNIEnv*, jclass, jmethodID, -+ jboolean (JNICALL *CallStaticBooleanMethodA)(JNIEnv*, jclass, jmethodID, - jvalue*); -- jbyte (*CallStaticByteMethod)(JNIEnv*, jclass, jmethodID, ...); -- jbyte (*CallStaticByteMethodV)(JNIEnv*, jclass, jmethodID, va_list); -- jbyte (*CallStaticByteMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -- jchar (*CallStaticCharMethod)(JNIEnv*, jclass, jmethodID, ...); -- jchar (*CallStaticCharMethodV)(JNIEnv*, jclass, jmethodID, va_list); -- jchar (*CallStaticCharMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -- jshort (*CallStaticShortMethod)(JNIEnv*, jclass, jmethodID, ...); -- jshort (*CallStaticShortMethodV)(JNIEnv*, jclass, jmethodID, va_list); -- jshort (*CallStaticShortMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -- jint (*CallStaticIntMethod)(JNIEnv*, jclass, jmethodID, ...); -- jint (*CallStaticIntMethodV)(JNIEnv*, jclass, jmethodID, va_list); -- jint (*CallStaticIntMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -- jlong (*CallStaticLongMethod)(JNIEnv*, jclass, jmethodID, ...); -- jlong (*CallStaticLongMethodV)(JNIEnv*, jclass, jmethodID, va_list); -- jlong (*CallStaticLongMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -- jfloat (*CallStaticFloatMethod)(JNIEnv*, jclass, jmethodID, ...); -- jfloat (*CallStaticFloatMethodV)(JNIEnv*, jclass, jmethodID, va_list); -- jfloat (*CallStaticFloatMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -- jdouble (*CallStaticDoubleMethod)(JNIEnv*, jclass, jmethodID, ...); -- jdouble (*CallStaticDoubleMethodV)(JNIEnv*, jclass, jmethodID, va_list); -- jdouble (*CallStaticDoubleMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -- void (*CallStaticVoidMethod)(JNIEnv*, jclass, jmethodID, ...); -- void (*CallStaticVoidMethodV)(JNIEnv*, jclass, jmethodID, va_list); -- void (*CallStaticVoidMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -- -- jfieldID (*GetStaticFieldID)(JNIEnv*, jclass, const char*, -+ jbyte (JNICALL *CallStaticByteMethod)(JNIEnv*, jclass, jmethodID, ...); -+ jbyte (JNICALL *CallStaticByteMethodV)(JNIEnv*, jclass, jmethodID, va_list); -+ jbyte (JNICALL *CallStaticByteMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -+ jchar (JNICALL *CallStaticCharMethod)(JNIEnv*, jclass, jmethodID, ...); -+ jchar (JNICALL *CallStaticCharMethodV)(JNIEnv*, jclass, jmethodID, va_list); -+ jchar (JNICALL *CallStaticCharMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -+ jshort (JNICALL *CallStaticShortMethod)(JNIEnv*, jclass, jmethodID, ...); -+ jshort (JNICALL *CallStaticShortMethodV)(JNIEnv*, jclass, jmethodID, va_list); -+ jshort (JNICALL *CallStaticShortMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -+ jint (JNICALL *CallStaticIntMethod)(JNIEnv*, jclass, jmethodID, ...); -+ jint (JNICALL *CallStaticIntMethodV)(JNIEnv*, jclass, jmethodID, va_list); -+ jint (JNICALL *CallStaticIntMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -+ jlong (JNICALL *CallStaticLongMethod)(JNIEnv*, jclass, jmethodID, ...); -+ jlong (JNICALL *CallStaticLongMethodV)(JNIEnv*, jclass, jmethodID, va_list); -+ jlong (JNICALL *CallStaticLongMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -+ jfloat (JNICALL *CallStaticFloatMethod)(JNIEnv*, jclass, jmethodID, ...); -+ jfloat (JNICALL *CallStaticFloatMethodV)(JNIEnv*, jclass, jmethodID, va_list); -+ jfloat (JNICALL *CallStaticFloatMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -+ jdouble (JNICALL *CallStaticDoubleMethod)(JNIEnv*, jclass, jmethodID, ...); -+ jdouble (JNICALL *CallStaticDoubleMethodV)(JNIEnv*, jclass, jmethodID, va_list); -+ jdouble (JNICALL *CallStaticDoubleMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -+ void (JNICALL *CallStaticVoidMethod)(JNIEnv*, jclass, jmethodID, ...); -+ void (JNICALL *CallStaticVoidMethodV)(JNIEnv*, jclass, jmethodID, va_list); -+ void (JNICALL *CallStaticVoidMethodA)(JNIEnv*, jclass, jmethodID, jvalue*); -+ -+ jfieldID (JNICALL *GetStaticFieldID)(JNIEnv*, jclass, const char*, - const char*); - -- jobject (*GetStaticObjectField)(JNIEnv*, jclass, jfieldID); -- jboolean (*GetStaticBooleanField)(JNIEnv*, jclass, jfieldID); -- jbyte (*GetStaticByteField)(JNIEnv*, jclass, jfieldID); -- jchar (*GetStaticCharField)(JNIEnv*, jclass, jfieldID); -- jshort (*GetStaticShortField)(JNIEnv*, jclass, jfieldID); -- jint (*GetStaticIntField)(JNIEnv*, jclass, jfieldID); -- jlong (*GetStaticLongField)(JNIEnv*, jclass, jfieldID); -- jfloat (*GetStaticFloatField)(JNIEnv*, jclass, jfieldID); -- jdouble (*GetStaticDoubleField)(JNIEnv*, jclass, jfieldID); -- -- void (*SetStaticObjectField)(JNIEnv*, jclass, jfieldID, jobject); -- void (*SetStaticBooleanField)(JNIEnv*, jclass, jfieldID, jboolean); -- void (*SetStaticByteField)(JNIEnv*, jclass, jfieldID, jbyte); -- void (*SetStaticCharField)(JNIEnv*, jclass, jfieldID, jchar); -- void (*SetStaticShortField)(JNIEnv*, jclass, jfieldID, jshort); -- void (*SetStaticIntField)(JNIEnv*, jclass, jfieldID, jint); -- void (*SetStaticLongField)(JNIEnv*, jclass, jfieldID, jlong); -- void (*SetStaticFloatField)(JNIEnv*, jclass, jfieldID, jfloat); -- void (*SetStaticDoubleField)(JNIEnv*, jclass, jfieldID, jdouble); -- -- jstring (*NewString)(JNIEnv*, const jchar*, jsize); -- jsize (*GetStringLength)(JNIEnv*, jstring); -- const jchar* (*GetStringChars)(JNIEnv*, jstring, jboolean*); -- void (*ReleaseStringChars)(JNIEnv*, jstring, const jchar*); -- jstring (*NewStringUTF)(JNIEnv*, const char*); -- jsize (*GetStringUTFLength)(JNIEnv*, jstring); -+ jobject (JNICALL *GetStaticObjectField)(JNIEnv*, jclass, jfieldID); -+ jboolean (JNICALL *GetStaticBooleanField)(JNIEnv*, jclass, jfieldID); -+ jbyte (JNICALL *GetStaticByteField)(JNIEnv*, jclass, jfieldID); -+ jchar (JNICALL *GetStaticCharField)(JNIEnv*, jclass, jfieldID); -+ jshort (JNICALL *GetStaticShortField)(JNIEnv*, jclass, jfieldID); -+ jint (JNICALL *GetStaticIntField)(JNIEnv*, jclass, jfieldID); -+ jlong (JNICALL *GetStaticLongField)(JNIEnv*, jclass, jfieldID); -+ jfloat (JNICALL *GetStaticFloatField)(JNIEnv*, jclass, jfieldID); -+ jdouble (JNICALL *GetStaticDoubleField)(JNIEnv*, jclass, jfieldID); -+ -+ void (JNICALL *SetStaticObjectField)(JNIEnv*, jclass, jfieldID, jobject); -+ void (JNICALL *SetStaticBooleanField)(JNIEnv*, jclass, jfieldID, jboolean); -+ void (JNICALL *SetStaticByteField)(JNIEnv*, jclass, jfieldID, jbyte); -+ void (JNICALL *SetStaticCharField)(JNIEnv*, jclass, jfieldID, jchar); -+ void (JNICALL *SetStaticShortField)(JNIEnv*, jclass, jfieldID, jshort); -+ void (JNICALL *SetStaticIntField)(JNIEnv*, jclass, jfieldID, jint); -+ void (JNICALL *SetStaticLongField)(JNIEnv*, jclass, jfieldID, jlong); -+ void (JNICALL *SetStaticFloatField)(JNIEnv*, jclass, jfieldID, jfloat); -+ void (JNICALL *SetStaticDoubleField)(JNIEnv*, jclass, jfieldID, jdouble); -+ -+ jstring (JNICALL *NewString)(JNIEnv*, const jchar*, jsize); -+ jsize (JNICALL *GetStringLength)(JNIEnv*, jstring); -+ const jchar* (JNICALL *GetStringChars)(JNIEnv*, jstring, jboolean*); -+ void (JNICALL *ReleaseStringChars)(JNIEnv*, jstring, const jchar*); -+ jstring (JNICALL *NewStringUTF)(JNIEnv*, const char*); -+ jsize (JNICALL *GetStringUTFLength)(JNIEnv*, jstring); - /* JNI spec says this returns const jbyte*, but that's inconsistent */ -- const char* (*GetStringUTFChars)(JNIEnv*, jstring, jboolean*); -- void (*ReleaseStringUTFChars)(JNIEnv*, jstring, const char*); -- jsize (*GetArrayLength)(JNIEnv*, jarray); -- jobjectArray (*NewObjectArray)(JNIEnv*, jsize, jclass, jobject); -- jobject (*GetObjectArrayElement)(JNIEnv*, jobjectArray, jsize); -- void (*SetObjectArrayElement)(JNIEnv*, jobjectArray, jsize, jobject); -- -- jbooleanArray (*NewBooleanArray)(JNIEnv*, jsize); -- jbyteArray (*NewByteArray)(JNIEnv*, jsize); -- jcharArray (*NewCharArray)(JNIEnv*, jsize); -- jshortArray (*NewShortArray)(JNIEnv*, jsize); -- jintArray (*NewIntArray)(JNIEnv*, jsize); -- jlongArray (*NewLongArray)(JNIEnv*, jsize); -- jfloatArray (*NewFloatArray)(JNIEnv*, jsize); -- jdoubleArray (*NewDoubleArray)(JNIEnv*, jsize); -- -- jboolean* (*GetBooleanArrayElements)(JNIEnv*, jbooleanArray, jboolean*); -- jbyte* (*GetByteArrayElements)(JNIEnv*, jbyteArray, jboolean*); -- jchar* (*GetCharArrayElements)(JNIEnv*, jcharArray, jboolean*); -- jshort* (*GetShortArrayElements)(JNIEnv*, jshortArray, jboolean*); -- jint* (*GetIntArrayElements)(JNIEnv*, jintArray, jboolean*); -- jlong* (*GetLongArrayElements)(JNIEnv*, jlongArray, jboolean*); -- jfloat* (*GetFloatArrayElements)(JNIEnv*, jfloatArray, jboolean*); -- jdouble* (*GetDoubleArrayElements)(JNIEnv*, jdoubleArray, jboolean*); -- -- void (*ReleaseBooleanArrayElements)(JNIEnv*, jbooleanArray, -+ const char* (JNICALL *GetStringUTFChars)(JNIEnv*, jstring, jboolean*); -+ void (JNICALL *ReleaseStringUTFChars)(JNIEnv*, jstring, const char*); -+ jsize (JNICALL *GetArrayLength)(JNIEnv*, jarray); -+ jobjectArray (JNICALL *NewObjectArray)(JNIEnv*, jsize, jclass, jobject); -+ jobject (JNICALL *GetObjectArrayElement)(JNIEnv*, jobjectArray, jsize); -+ void (JNICALL *SetObjectArrayElement)(JNIEnv*, jobjectArray, jsize, jobject); -+ -+ jbooleanArray (JNICALL *NewBooleanArray)(JNIEnv*, jsize); -+ jbyteArray (JNICALL *NewByteArray)(JNIEnv*, jsize); -+ jcharArray (JNICALL *NewCharArray)(JNIEnv*, jsize); -+ jshortArray (JNICALL *NewShortArray)(JNIEnv*, jsize); -+ jintArray (JNICALL *NewIntArray)(JNIEnv*, jsize); -+ jlongArray (JNICALL *NewLongArray)(JNIEnv*, jsize); -+ jfloatArray (JNICALL *NewFloatArray)(JNIEnv*, jsize); -+ jdoubleArray (JNICALL *NewDoubleArray)(JNIEnv*, jsize); -+ -+ jboolean* (JNICALL *GetBooleanArrayElements)(JNIEnv*, jbooleanArray, jboolean*); -+ jbyte* (JNICALL *GetByteArrayElements)(JNIEnv*, jbyteArray, jboolean*); -+ jchar* (JNICALL *GetCharArrayElements)(JNIEnv*, jcharArray, jboolean*); -+ jshort* (JNICALL *GetShortArrayElements)(JNIEnv*, jshortArray, jboolean*); -+ jint* (JNICALL *GetIntArrayElements)(JNIEnv*, jintArray, jboolean*); -+ jlong* (JNICALL *GetLongArrayElements)(JNIEnv*, jlongArray, jboolean*); -+ jfloat* (JNICALL *GetFloatArrayElements)(JNIEnv*, jfloatArray, jboolean*); -+ jdouble* (JNICALL *GetDoubleArrayElements)(JNIEnv*, jdoubleArray, jboolean*); -+ -+ void (JNICALL *ReleaseBooleanArrayElements)(JNIEnv*, jbooleanArray, - jboolean*, jint); -- void (*ReleaseByteArrayElements)(JNIEnv*, jbyteArray, -+ void (JNICALL *ReleaseByteArrayElements)(JNIEnv*, jbyteArray, - jbyte*, jint); -- void (*ReleaseCharArrayElements)(JNIEnv*, jcharArray, -+ void (JNICALL *ReleaseCharArrayElements)(JNIEnv*, jcharArray, - jchar*, jint); -- void (*ReleaseShortArrayElements)(JNIEnv*, jshortArray, -+ void (JNICALL *ReleaseShortArrayElements)(JNIEnv*, jshortArray, - jshort*, jint); -- void (*ReleaseIntArrayElements)(JNIEnv*, jintArray, -+ void (JNICALL *ReleaseIntArrayElements)(JNIEnv*, jintArray, - jint*, jint); -- void (*ReleaseLongArrayElements)(JNIEnv*, jlongArray, -+ void (JNICALL *ReleaseLongArrayElements)(JNIEnv*, jlongArray, - jlong*, jint); -- void (*ReleaseFloatArrayElements)(JNIEnv*, jfloatArray, -+ void (JNICALL *ReleaseFloatArrayElements)(JNIEnv*, jfloatArray, - jfloat*, jint); -- void (*ReleaseDoubleArrayElements)(JNIEnv*, jdoubleArray, -+ void (JNICALL *ReleaseDoubleArrayElements)(JNIEnv*, jdoubleArray, - jdouble*, jint); - -- void (*GetBooleanArrayRegion)(JNIEnv*, jbooleanArray, -+ void (JNICALL *GetBooleanArrayRegion)(JNIEnv*, jbooleanArray, - jsize, jsize, jboolean*); -- void (*GetByteArrayRegion)(JNIEnv*, jbyteArray, -+ void (JNICALL *GetByteArrayRegion)(JNIEnv*, jbyteArray, - jsize, jsize, jbyte*); -- void (*GetCharArrayRegion)(JNIEnv*, jcharArray, -+ void (JNICALL *GetCharArrayRegion)(JNIEnv*, jcharArray, - jsize, jsize, jchar*); -- void (*GetShortArrayRegion)(JNIEnv*, jshortArray, -+ void (JNICALL *GetShortArrayRegion)(JNIEnv*, jshortArray, - jsize, jsize, jshort*); -- void (*GetIntArrayRegion)(JNIEnv*, jintArray, -+ void (JNICALL *GetIntArrayRegion)(JNIEnv*, jintArray, - jsize, jsize, jint*); -- void (*GetLongArrayRegion)(JNIEnv*, jlongArray, -+ void (JNICALL *GetLongArrayRegion)(JNIEnv*, jlongArray, - jsize, jsize, jlong*); -- void (*GetFloatArrayRegion)(JNIEnv*, jfloatArray, -+ void (JNICALL *GetFloatArrayRegion)(JNIEnv*, jfloatArray, - jsize, jsize, jfloat*); -- void (*GetDoubleArrayRegion)(JNIEnv*, jdoubleArray, -+ void (JNICALL *GetDoubleArrayRegion)(JNIEnv*, jdoubleArray, - jsize, jsize, jdouble*); - - /* spec shows these without const; some jni.h do, some don't */ -- void (*SetBooleanArrayRegion)(JNIEnv*, jbooleanArray, -+ void (JNICALL *SetBooleanArrayRegion)(JNIEnv*, jbooleanArray, - jsize, jsize, const jboolean*); -- void (*SetByteArrayRegion)(JNIEnv*, jbyteArray, -+ void (JNICALL *SetByteArrayRegion)(JNIEnv*, jbyteArray, - jsize, jsize, const jbyte*); -- void (*SetCharArrayRegion)(JNIEnv*, jcharArray, -+ void (JNICALL *SetCharArrayRegion)(JNIEnv*, jcharArray, - jsize, jsize, const jchar*); -- void (*SetShortArrayRegion)(JNIEnv*, jshortArray, -+ void (JNICALL *SetShortArrayRegion)(JNIEnv*, jshortArray, - jsize, jsize, const jshort*); -- void (*SetIntArrayRegion)(JNIEnv*, jintArray, -+ void (JNICALL *SetIntArrayRegion)(JNIEnv*, jintArray, - jsize, jsize, const jint*); -- void (*SetLongArrayRegion)(JNIEnv*, jlongArray, -+ void (JNICALL *SetLongArrayRegion)(JNIEnv*, jlongArray, - jsize, jsize, const jlong*); -- void (*SetFloatArrayRegion)(JNIEnv*, jfloatArray, -+ void (JNICALL *SetFloatArrayRegion)(JNIEnv*, jfloatArray, - jsize, jsize, const jfloat*); -- void (*SetDoubleArrayRegion)(JNIEnv*, jdoubleArray, -+ void (JNICALL *SetDoubleArrayRegion)(JNIEnv*, jdoubleArray, - jsize, jsize, const jdouble*); - -- jint (*RegisterNatives)(JNIEnv*, jclass, const JNINativeMethod*, -+ jint (JNICALL *RegisterNatives)(JNIEnv*, jclass, const JNINativeMethod*, - jint); -- jint (*UnregisterNatives)(JNIEnv*, jclass); -- jint (*MonitorEnter)(JNIEnv*, jobject); -- jint (*MonitorExit)(JNIEnv*, jobject); -- jint (*GetJavaVM)(JNIEnv*, JavaVM**); -+ jint (JNICALL *UnregisterNatives)(JNIEnv*, jclass); -+ jint (JNICALL *MonitorEnter)(JNIEnv*, jobject); -+ jint (JNICALL *MonitorExit)(JNIEnv*, jobject); -+ jint (JNICALL *GetJavaVM)(JNIEnv*, JavaVM**); - -- void (*GetStringRegion)(JNIEnv*, jstring, jsize, jsize, jchar*); -- void (*GetStringUTFRegion)(JNIEnv*, jstring, jsize, jsize, char*); -+ void (JNICALL *GetStringRegion)(JNIEnv*, jstring, jsize, jsize, jchar*); -+ void (JNICALL *GetStringUTFRegion)(JNIEnv*, jstring, jsize, jsize, char*); - -- void* (*GetPrimitiveArrayCritical)(JNIEnv*, jarray, jboolean*); -- void (*ReleasePrimitiveArrayCritical)(JNIEnv*, jarray, void*, jint); -+ void* (JNICALL *GetPrimitiveArrayCritical)(JNIEnv*, jarray, jboolean*); -+ void (JNICALL *ReleasePrimitiveArrayCritical)(JNIEnv*, jarray, void*, jint); - -- const jchar* (*GetStringCritical)(JNIEnv*, jstring, jboolean*); -- void (*ReleaseStringCritical)(JNIEnv*, jstring, const jchar*); -+ const jchar* (JNICALL *GetStringCritical)(JNIEnv*, jstring, jboolean*); -+ void (JNICALL *ReleaseStringCritical)(JNIEnv*, jstring, const jchar*); - -- jweak (*NewWeakGlobalRef)(JNIEnv*, jobject); -- void (*DeleteWeakGlobalRef)(JNIEnv*, jweak); -+ jweak (JNICALL *NewWeakGlobalRef)(JNIEnv*, jobject); -+ void (JNICALL *DeleteWeakGlobalRef)(JNIEnv*, jweak); - -- jboolean (*ExceptionCheck)(JNIEnv*); -+ jboolean (JNICALL *ExceptionCheck)(JNIEnv*); - -- jobject (*NewDirectByteBuffer)(JNIEnv*, void*, jlong); -- void* (*GetDirectBufferAddress)(JNIEnv*, jobject); -- jlong (*GetDirectBufferCapacity)(JNIEnv*, jobject); -+ jobject (JNICALL *NewDirectByteBuffer)(JNIEnv*, void*, jlong); -+ void* (JNICALL *GetDirectBufferAddress)(JNIEnv*, jobject); -+ jlong (JNICALL *GetDirectBufferCapacity)(JNIEnv*, jobject); - - /* added in JNI 1.6 */ -- jobjectRefType (*GetObjectRefType)(JNIEnv*, jobject); -+ jobjectRefType (JNICALL *GetObjectRefType)(JNIEnv*, jobject); - }; - - /* -@@ -1053,11 +1063,11 @@ struct JNIInvokeInterface { - void* reserved1; - void* reserved2; - -- jint (*DestroyJavaVM)(JavaVM*); -- jint (*AttachCurrentThread)(JavaVM*, JNIEnv**, void*); -- jint (*DetachCurrentThread)(JavaVM*); -- jint (*GetEnv)(JavaVM*, void**, jint); -- jint (*AttachCurrentThreadAsDaemon)(JavaVM*, JNIEnv**, void*); -+ jint (JNICALL *DestroyJavaVM)(JavaVM*); -+ jint (JNICALL *AttachCurrentThread)(JavaVM*, JNIEnv**, void*); -+ jint (JNICALL *DetachCurrentThread)(JavaVM*); -+ jint (JNICALL *GetEnv)(JavaVM*, void**, jint); -+ jint (JNICALL *AttachCurrentThreadAsDaemon)(JavaVM*, JNIEnv**, void*); - }; - - /* -@@ -1118,10 +1128,6 @@ jint JNI_CreateJavaVM(JavaVM**, JNIEnv**, void*); - jint JNI_GetCreatedJavaVMs(JavaVM**, jsize, jsize*); - #endif - --#define JNIIMPORT --#define JNIEXPORT __attribute__ ((visibility ("default"))) --#define JNICALL -- - /* - * Prototypes for functions exported by loadable shared libs. These are - * called by JNI, not provided by JNI. diff --git a/chrome/test/chromedriver/window_commands.cc b/chrome/test/chromedriver/window_commands.cc index 30f87c1cc3..10d94733ec 100644 --- a/chrome/test/chromedriver/window_commands.cc +++ b/chrome/test/chromedriver/window_commands.cc @@ -10,7 +10,7 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" #include "base/threading/platform_thread.h" -#include "base/time.h" +#include "base/time/time.h" #include "base/values.h" #include "chrome/test/chromedriver/basic_types.h" #include "chrome/test/chromedriver/chrome/chrome.h" diff --git a/chrome/test/functional/PYAUTO_TESTS b/chrome/test/functional/PYAUTO_TESTS index 8a96f74cdc..8895d00e57 100644 --- a/chrome/test/functional/PYAUTO_TESTS +++ b/chrome/test/functional/PYAUTO_TESTS @@ -41,7 +41,6 @@ 'extensions', 'fullscreen_mouselock', 'gtalk.test_basic', - 'imports', 'infobars', 'media.media_basic_playback', 'multiprofile', @@ -152,12 +151,6 @@ '-extensions.ExtensionsTest.testAllowAccessFileURLs', # crbug.com/113090 '-extensions.ExtensionsTest.testAllowIncognitoExtension', - # Disabled on vista in the actual test. crbug.com/89767 - # -imports.ImportsTest.testImportFirefoxDataTwice - # Disabled on vista in the actual test. crbug.com/89767 - # -imports.ImportsTest.testFirefoxImportFromPrefs - # Disabled on vista in the actual test. crbug.com/89767 - # -imports.ImportsTest.testImportFirefoxPasswordsFromPrefs # crbug.com/171490 '-passwords.PasswordTest.testPasswdInfoNotStoredWhenAutocompleteOff', # crbug.com/117569 @@ -186,8 +179,6 @@ # Fails on chrome-mac-10_7-qa only: crbug.com/124886 '-fullscreen_mouselock.FullscreenMouselockTest.testPrefsForFullscreenExit', '-fullscreen_mouselock.FullscreenMouselockTest.testNoMouseLockWhenCancelFS', - # crbug.com/114244 - '-imports.ImportsTest.testImportSafariDataTwice', # crbug.com/121484 '-multiprofile.MultiprofileTest.test20NewProfiles', '-ntp.NTPTest.testLaunchAppNewWindow', # crbug.com/79812 @@ -243,8 +234,6 @@ # =========================== # No codesign verification on ChromeOS. '-codesign', - # Import tests are invalid on ChromeOS since Chrome is the only browser. - '-imports', # Sync is already signed in with the login account. # So one-click infobar tests do tno apply to chromeos. '-infobars.OneClickInfobarTest', @@ -506,6 +495,12 @@ 'WEBRTC_APPRTC': { 'all': [ 'webrtc_apprtc_call', + # ================================================== + # Disabled tests that need to be investigated/fixed. + # ================================================== + # crbug.com/254412 + '-webrtc_apprtc_call.WebrtcApprtcCallTest.testApprtcTabToTabCall', + '-webrtc_apprtc_call.WebrtcApprtcCallTest.testApprtcLoopbackCall', ], }, @@ -516,7 +511,8 @@ 'WEBRTC_QUALITY': { 'all': [ 'webrtc_video_quality', - 'webrtc_audio_quality', + # Disabled until crbug.com/254437 is resolved. + '-webrtc_audio_quality', ], 'mac': [ '-webrtc_audio_quality', # Not implemented. diff --git a/chrome/test/functional/imports.py b/chrome/test/functional/imports.py deleted file mode 100755 index 443deec437..0000000000 --- a/chrome/test/functional/imports.py +++ /dev/null @@ -1,360 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) 2012 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. - -import glob -import logging -import optparse -import os -import shutil -import sys -import tempfile -import zipfile - - -import pyauto_functional # Must be imported before pyauto -import pyauto -import pyauto_utils - - -class ImportsTest(pyauto.PyUITest): - """Import settings from other browsers. - - Import settings tables below show which items get imported on first run and - via preferences for different browsers and operating systems. - - Bookmarks History SearchEngines Passwords Homepage - Firefox: - Win/FRUI N Y N N Y - Win/Prefs Y Y Y Y N - Mac&Lin/FRUI Y Y Y Y Y - Mac&Lin/Prefs Y Y Y Y N - - Safari: - Mac/FRUI Y Y Y Y N - Mac/Prefs Y Y Y Y N - """ - def setUp(self): - self._to_import = ['ALL'] - - if pyauto.PyUITest.IsMac(): - self._firefox_profiles_path = os.path.join( - os.environ['HOME'], 'Library','Application Support','Firefox') - self._firefox_test_profile = os.path.abspath(os.path.join( - pyauto.PyUITest.DataDir(), 'import', 'firefox', 'macwin.zip')) - self._safari_profiles_path = os.path.join( - os.environ['HOME'], 'Library', 'Safari') - # Don't import passwords to avoid Keychain popups. See crbug.com/49378. - self._to_import = ['HISTORY', 'FAVORITES', 'SEARCH_ENGINES', 'HOME_PAGE'] - elif pyauto.PyUITest.IsWin(): - self._firefox_profiles_path = os.path.join( - os.getenv('APPDATA'), 'Mozilla', 'Firefox') - self._firefox_test_profile = os.path.abspath(os.path.join( - pyauto.PyUITest.DataDir(), 'import', 'firefox', 'macwin.zip')) - else: # Linux - self._firefox_profiles_path = os.path.join( - os.environ['HOME'], '.mozilla', 'firefox') - self._firefox_test_profile = os.path.abspath(os.path.join( - pyauto.PyUITest.DataDir(), 'import', 'firefox', 'linux.zip')) - - # Expected items for tests. - self._history_items = ['Google', 'Google News', u'Google \ub3c4\uc11c'] - self._bookmark_bar_items = ['Google News', 'Google', u'Google \ub3c4\uc11c'] - self._bookmark_folder_items = [] - self._password_items = ['etouchqa@gmail.com', 'macqa05'] - self._home_page = 'http://news.google.com/' - - self._safari_replacer = None - self._firefox_replacer = None - - pyauto.PyUITest.setUp(self) - - def tearDown(self): - pyauto.PyUITest.tearDown(self) - # Delete any replacers to restore the original profiles. - if self._safari_replacer: - del self._safari_replacer - if self._firefox_replacer: - del self._firefox_replacer - - def _UnzipProfileToDir(self, profile_zip, dir): - """Unzip |profile_zip| into directory |dir|. - - Creates |dir| if it doesn't exist. - """ - if not os.path.isdir(dir): - os.makedirs(dir) - zf = zipfile.ZipFile(profile_zip) - for name in zf.namelist(): - full_path = os.path.join(dir, name) - if name.endswith('/'): - if not os.path.isdir(full_path): - os.makedirs(full_path) - else: - zf.extract(name, dir) - os.chmod(full_path, 0777) - - def _SwapFirefoxProfile(self): - """Swaps the test Firefox profile with the original one.""" - self._firefox_replacer = pyauto_utils.ExistingPathReplacer( - self._firefox_profiles_path) - self._UnzipProfileToDir(self._firefox_test_profile, - self._firefox_profiles_path) - - def _SwapSafariProfile(self): - """Swaps the test Safari profile with the original one.""" - self._safari_replacer = pyauto_utils.ExistingPathReplacer( - self._safari_profiles_path) - self._UnzipProfileToDir( - os.path.join(self.DataDir(), 'import', 'safari', 'mac.zip'), - self._safari_profiles_path) - - def _CheckForBookmarks(self, bookmark_titles, bookmark_bar, window_index=0): - """Checks that the given bookmarks exist. - - Args: - bookmark_titles: A set of bookmark title strings. - bookmark_bar: True if the bookmarks are part of the bookmark bar. - False otherwise. - window_index: The window index, default is 0. - """ - bookmarks = self.GetBookmarkModel(window_index) - if bookmark_bar: - node = bookmarks.BookmarkBar() - else: - node = bookmarks.Other() - for title in bookmark_titles: - self.assertTrue([x for x in bookmark_titles \ - if bookmarks.FindByTitle(title, [node])]) - - def _BookmarkDuplicatesExist(self, bookmark_titles): - """Returns true if any of the bookmark titles are duplicated. - - Args: - bookmark_titles: A list of bookmark title strings. - """ - bookmarks = self.GetBookmarkModel() - for title in bookmark_titles: - if len(bookmarks.FindByTitle(title)) > 1: - return True - return False - - def _CheckForHistory(self, history_titles): - """Verifies that the given list of history items are in the history. - - Args: - history_titles: A list of history title strings. - """ - history = self.GetHistoryInfo().History() - - # History import automation is broken - crbug.com/63001 - return - - for title in history_titles: - self.assertTrue([x for x in history if x['title'] == title]) - - def _CheckForPasswords(self, usernames): - """Check that password items exist for the given usernames.""" - # Password import automation does not work on Mac. See crbug.com/52124. - if self.IsMac(): - return - passwords = self.GetSavedPasswords() - for username in usernames: - self.assertTrue([x for x in passwords if x['username_value'] == username]) - - def _CheckDefaults(self, bookmarks, history, passwords, home_page, - search_engines, window_index=0): - """Checks the defaults for each of the possible import items. - - All arguments are True if they should be checked, False otherwise.""" - if bookmarks: - self._CheckForBookmarks(self._bookmark_bar_items, True, window_index) - self._CheckForBookmarks(self._bookmark_folder_items, False, window_index) - if history: - self._CheckForHistory(self._history_items) - if passwords: - self._CheckForPasswords(self._password_items) - if home_page: - self.assertEqual(self._home_page, self.GetPrefsInfo().Prefs()['homepage']) - # TODO(alyssad): Test for search engines after a hook is added. - # See crbug.com/52009. - - def _CanRunFirefoxTests(self): - """Determine whether we can run firefox imports. - - On windows, checks if firefox is installed. Always True on other platforms. - """ - if self.IsWin(): - ff_installed = os.path.exists(os.path.join( - os.getenv('ProgramFiles'), 'Mozilla Firefox', 'firefox.exe')) - if not ff_installed: - logging.warn('Firefox not installed.') - return ff_installed - # TODO(nirnimesh): Anything else to be done on other platforms? - return True - - def _ImportFromFirefox(self, bookmarks, history, passwords, home_page, - search_engines, window_index=0): - """Verify importing individual Firefox data through preferences""" - if not self._CanRunFirefoxTests(): - logging.warn('Not running firefox import tests.') - return - self._SwapFirefoxProfile() - self.ImportSettings('Mozilla Firefox', self._to_import, window_index) - self._CheckDefaults(bookmarks, history, passwords, home_page, - search_engines, window_index) - - def _GetProfilePath(self): - """Get profile paths when multiprofile windows are open. - - Returns: - profile: Path for multiprofiles. - """ - profiles_list = self.GetMultiProfileInfo()['profiles'] - profile1_path = profile2_path = default_path = None - for profile in profiles_list: - if profile['path'].find('Profile 1') != -1: - profile1_path = profile['path'] - elif profile['path'].find('Profile 2') != -1: - profile2_path = profile['path'] - elif profile['path'].find('Default') != -1: - default_path = profile['path'] - return default_path, profile1_path, profile2_path - - # Tests. - def testFirefoxImportFromPrefs(self): - """Verify importing Firefox data through preferences.""" - if not self._CanRunFirefoxTests(): - logging.warn('Not running firefox import tests.') - return - if self.IsWinVista(): # Broken on vista. crbug.com/89768 - return - self._SwapFirefoxProfile() - self.ImportSettings('Mozilla Firefox', self._to_import) - self._CheckDefaults(bookmarks=True, history=True, passwords=True, - home_page=False, search_engines=True) - - def testImportFirefoxDataTwice(self): - """Verify importing Firefox data twice. - - Bookmarks should be duplicated, but history and passwords should not. - """ - if not self._CanRunFirefoxTests(): - logging.warn('Not running firefox import tests.') - return - if self.IsWinVista(): # Broken on vista. crbug.com/89768 - return - self._SwapFirefoxProfile() - self.ImportSettings('Mozilla Firefox', self._to_import) - num_history_orig = len(self.GetHistoryInfo().History()) - num_passwords_orig = len(self.GetSavedPasswords()) - - # Re-import and check for duplicates. - self.ImportSettings('Mozilla Firefox', self._to_import) - self.assertTrue(self._BookmarkDuplicatesExist( - self._bookmark_bar_items + self._bookmark_folder_items)) - self.assertEqual(num_history_orig, len(self.GetHistoryInfo().History())) - self.assertEqual(num_passwords_orig, len(self.GetSavedPasswords())) - - def testImportFirefoxBookmarksFromPrefs(self): - """Verify importing Firefox bookmarks through preferences.""" - self._ImportFromFirefox(bookmarks=True, history=False, passwords=False, - home_page=False, search_engines=False) - - def testImportFirefoxHistoryFromPrefs(self): - """Verify importing Firefox history through preferences.""" - self._ImportFromFirefox(bookmarks=False, history=True, passwords=False, - home_page=False, search_engines=False) - - def testImportFirefoxPasswordsFromPrefs(self): - """Verify importing Firefox passwords through preferences.""" - if self.IsWinVista(): # Broken on vista. crbug.com/89768 - return - self._ImportFromFirefox(bookmarks=False, history=False, passwords=True, - home_page=False, search_engines=False) - - def testImportFirefoxSearchEnginesFromPrefs(self): - """Verify importing Firefox search engines through preferences.""" - self._ImportFromFirefox(bookmarks=False, history=False, passwords=False, - home_page=False, search_engines=True) - - def testImportFromFirefoxAndSafari(self): - """Verify importing from Firefox and then Safari.""" - # This test is for Mac only. - if not self.IsMac(): - return - - self._SwapSafariProfile() - self._SwapFirefoxProfile() - self.ImportSettings('Mozilla Firefox', self._to_import) - self.ImportSettings('Safari', self._to_import) - - self._CheckDefaults(bookmarks=True, history=True, passwords=True, - home_page=False, search_engines=True) - self.assertTrue(self._BookmarkDuplicatesExist( - self._bookmark_bar_items + self._bookmark_folder_items)) - - def testSafariImportFromPrefs(self): - """Verify importing Safari data through preferences.""" - # This test is Mac only. - if not self.IsMac(): - return - self._SwapSafariProfile() - self.ImportSettings('Safari', self._to_import) - self._CheckDefaults(bookmarks=True, history=True, passwords=False, - home_page=False, search_engines=True) - - def testImportSafariDataTwice(self): - """Verify importing Safari data twice. - - Bookmarks should be duplicated, but history and passwords should not.""" - # This test is Mac only. - if not self.IsMac(): - return - self._SwapSafariProfile() - self.ImportSettings('Safari', self._to_import) - num_history_orig = len(self.GetHistoryInfo().History()) - num_passwords_orig = len(self.GetSavedPasswords()) - - # Re-import and check for duplicates. - self.ImportSettings('Safari', self._to_import) - self.assertTrue(self._BookmarkDuplicatesExist( - self._bookmark_bar_items + self._bookmark_folder_items)) - self.assertEqual(num_history_orig, len(self.GetHistoryInfo().History())) - self.assertEqual(num_passwords_orig, len(self.GetSavedPasswords())) - - def testFireFoxImportBookmarksMultiProfile(self): - """Verify importing Firefox bookmarks through preferences. - - Bookmarks are imported from Firefox through the preferences for multiple - profiles.""" - # Create new profile, import bookmarks from firefox. - self.OpenNewBrowserWindowWithNewProfile() - self._ImportFromFirefox(bookmarks=True, history=False, - passwords=False, home_page=False, - search_engines=False, window_index=1) - # Create new profile, add 'BING', 'DB' as bookmark. - self.OpenNewBrowserWindowWithNewProfile() - bookmarks = self.GetBookmarkModel(2) - bar_id = bookmarks.BookmarkBar()['id'] - self.AddBookmarkURL(bar_id, 0, 'BING', 'http://www.bing.com/', 2) - self.AddBookmarkURL(bar_id, 0, 'DB', 'http://www.oracle.com/', 2) - default_path, profile1_path, profile2_path = self._GetProfilePath() - # Close profile1/profile2 windows. - self.CloseBrowserWindow(2) - self.CloseBrowserWindow(1) - # Launch profile2. - self.OpenProfileWindow(path=profile2_path) - # Verify bookmark imported from firefox 'GoogleNews' in - # profile2 is not present. - bookmarks = self.GetBookmarkModel(1) - node = bookmarks.FindByTitle('GoogleNews') - self.assertEqual(0, len(node)) - # Assert if 'BING' is present. - node = bookmarks.FindByTitle('BING') - self.assertEqual(1, len(node)) - - -if __name__ == '__main__': - pyauto_functional.Main() diff --git a/chrome/test/functional/ispy/image_tools.py b/chrome/test/functional/ispy/image_tools.py new file mode 100644 index 0000000000..bf0402ad95 --- /dev/null +++ b/chrome/test/functional/ispy/image_tools.py @@ -0,0 +1,222 @@ +# Copyright 2013 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. + +"""Utilities for performing pixel-by-pixel image comparision.""" + +import itertools +import StringIO +import PIL +from PIL import Image + + +def _AreTheSameSize(images): + """Returns whether a set of images are the size size. + + Args: + images: a list of images to compare. + + Returns: + boolean. + + Raises: + Exception: One image or fewer is passed in. + """ + if len(images) > 1: + return all(images[0].size == img.size for img in images[1:]) + else: + raise Exception('No images passed in.') + + +def _GetDifferenceWithMask(image1, image2, mask=None, + masked_color=(0, 0, 0), + same_color=(0, 0, 0), + different_color=(255, 255, 255)): + """Returns an image representing the difference between the two images. + + This function computes the difference between two images taking into + account a mask if it is provided. The final three arguments represent + the coloration of the generated image. + + Args: + image1: the first image to compare. + image2: the second image to compare. + mask: an optional mask image consisting of only black and white pixels + where white pixels indicate the portion of the image to be masked out. + masked_color: the color of a masked section in the resulting image. + same_color: the color of an unmasked section that is the same. + between images 1 and 2 in the resulting image. + different_color: the color of an unmasked section that is different + between images 1 and 2 in the resulting image. + + Returns: + an image repesenting the difference between the two images. + + Raises: + Exception: if image1, image2, and mask are not the same size. + """ + image_mask = mask + if not mask: + image_mask = PIL.Image.new('RGB', image1.size, (0, 0, 0)) + if not _AreTheSameSize([image1, image2, image_mask]): + raise Exception('images and mask must be the same size.') + image_diff = PIL.Image.new('RGB', image1.size, (0, 0, 0)) + data = [] + for m, px1, px2 in itertools.izip(image_mask.getdata(), + image1.getdata(), + image2.getdata()): + if m == (255, 255, 255): + data.append(masked_color) + elif px1 == px2: + data.append(same_color) + else: + data.append(different_color) + + image_diff.putdata(data) + return image_diff + + +def CreateMask(images): + """Computes a mask for a set of images. + + Returns a difference mask that is computed from the images + which are passed in. The mask will have a white pixel + anywhere that the input images differ and a black pixel + everywhere else. + + Args: + images: the images to compute the mask from. + + Returns: + an image of only black and white pixels where white pixels represent + areas in the input images that have differences. + + Raises: + Exception: if the images passed in are not of the same size. + Exception: if fewer than two images are passed in. + """ + if len(images) < 2: + raise Exception('mask must be created from two or more images.') + mask = Image.new('RGB', images[0].size, (0, 0, 0)) + image = images[0] + for other_image in images[1:]: + mask = _GetDifferenceWithMask( + image, + other_image, + mask, + masked_color=(255, 255, 255)) + return mask + + +def VisualizeImageDifferences(image1, image2, mask=None): + """Returns an image repesenting the unmasked differences between two images. + + Iterates through the pixel values of two images and an optional + mask. If the pixel values are the same, or the pixel is masked, + (0,0,0) is stored for that pixel. Otherwise, (255,255,255) is stored. + This ultimately produces an image where unmasked differences between + the two images are white pixels, and everything else is black. + + Args: + image1: an RGB image + image2: another RGB image of the same size as image1. + mask: an optional RGB image consisting of only white and black pixels + where the white pixels represent the parts of the images to be masked + out. + + Returns: + a black and white image representing the unmasked difference between + the two input images. + + Raises: + Exception: if the two images and optional mask are different sizes. + """ + return _GetDifferenceWithMask(image1, image2, mask) + + +def TotalDifferentPixels(image1, image2, mask=None): + """Computes the number of different pixels between two images. + + Args: + image1: the first RGB image to be compared. + image2: the second RGB image to be compared. + mask: an optional RGB image of only black and white pixels + where white pixels indicate the parts of the image to be masked out. + + Returns: + the number of differing pixels between the images. + + Raises: + Exception: if the images to be compared and the mask are not the same size. + """ + image_mask = mask + if not mask: + image_mask = PIL.Image.new('RGB', image1.size, (0, 0, 0)) + if _AreTheSameSize([image1, image2, image_mask]): + total_diff = 0 + for px1, px2, m in itertools.izip(image1.getdata(), + image2.getdata(), + image_mask.getdata()): + if m == (255, 255, 255): + continue + elif px1 != px2: + total_diff += 1 + else: + continue + return total_diff + else: + raise Exception('images and mask must be the same size') + + +def SameImage(image1, image2, mask=None): + """Returns a boolean representing whether the images are the same. + + Returns a boolean indicating whether two images are similar + enough to be considered the same. Essentially wraps the + TotalDifferentPixels function. + + + Args: + image1: an RGB image to compare. + image2: an RGB image to compare. + mask: an optional image of only black and white pixels + where white pixels are masked out + + Returns: + True if the images are similar, False otherwise. + + Raises: + Exception: if the images (and mask) are different sizes. + """ + different_pixels = TotalDifferentPixels(image1, image2, mask) + return different_pixels == 0 + + +def SerializeImage(image): + """Returns a base64 encoded version of the file-contents of the image. + + Args: + image: an RGB image to be encoded. + + Returns: + a base64 encoded string representing the image. + """ + f = StringIO.StringIO() + image.save(f, 'PNG') + encoded_image = f.getvalue().encode('base64') + f.close() + return encoded_image + + +def DeserializeImage(encoded_image): + """Returns an RGB image from a base64 encoded string. + + Args: + encoded_image: a base64 encoded string representation of an RGB image. + + Returns: + an RGB image + """ + return PIL.Image.open(StringIO.StringIO(encoded_image.decode('base64'))) + + diff --git a/chrome/test/functional/ispy/image_tools_test.py b/chrome/test/functional/ispy/image_tools_test.py new file mode 100644 index 0000000000..4ae5793faf --- /dev/null +++ b/chrome/test/functional/ispy/image_tools_test.py @@ -0,0 +1,189 @@ +# Copyright 2013 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. + +import unittest +from PIL import Image + +import image_tools + + +def _GenImage(size, color): + return Image.new('RGB', size, color) + + +def _AllPixelsOfColor(image, color): + return not any(px != color for px in image.getdata()) + + +class ImageToolsTest(unittest.TestCase): + + def testAreTheSameSize(self): + black25x25 = _GenImage((25, 25), (0, 0, 0)) + white25x25 = _GenImage((25, 25), (255, 255, 255)) + black50x50 = _GenImage((50, 50), (0, 0, 0)) + white50x50 = _GenImage((50, 50), (255, 255, 255)) + + self.assertTrue(image_tools._AreTheSameSize([black25x25, black25x25])) + self.assertTrue(image_tools._AreTheSameSize([white25x25, white25x25])) + self.assertTrue(image_tools._AreTheSameSize([black50x50, black50x50])) + self.assertTrue(image_tools._AreTheSameSize([white50x50, white50x50])) + self.assertTrue(image_tools._AreTheSameSize([black25x25, white25x25])) + self.assertTrue(image_tools._AreTheSameSize([black50x50, white50x50])) + + self.assertFalse(image_tools._AreTheSameSize([black50x50, black25x25])) + self.assertFalse(image_tools._AreTheSameSize([white50x50, white25x25])) + self.assertFalse(image_tools._AreTheSameSize([black25x25, white50x50])) + self.assertFalse(image_tools._AreTheSameSize([black50x50, white25x25])) + + self.assertRaises(Exception, image_tools._AreTheSameSize, []) + self.assertRaises(Exception, image_tools._AreTheSameSize, [black50x50]) + + def testGetDifferenceWithMask(self): + black25x25 = _GenImage((25, 25), (0, 0, 0)) + white25x25 = _GenImage((25, 25), (255, 255, 255)) + black50x50 = _GenImage((50, 50), (0, 0, 0)) + self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask( + black25x25, black25x25), (0, 0, 0))) + self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask( + white25x25, white25x25), (0, 0, 0))) + self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask( + white25x25, black25x25), (255, 255, 255))) + self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask( + black25x25, black25x25, mask=black25x25), (0, 0, 0))) + self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask( + black25x25, black25x25, mask=white25x25), (0, 0, 0))) + self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask( + black25x25, white25x25, mask=black25x25), (255, 255, 255))) + self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask( + black25x25, white25x25, mask=white25x25), (0, 0, 0))) + self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask( + black25x25, white25x25, different_color=(255, 0, 0)), (255, 0, 0))) + self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask( + white25x25, white25x25, same_color=(255, 0, 0)), (255, 0, 0))) + self.assertTrue(_AllPixelsOfColor(image_tools._GetDifferenceWithMask( + white25x25, white25x25, + mask=white25x25, masked_color=(255, 0, 0)), (255, 0, 0))) + self.assertRaises(Exception, image_tools._GetDifferenceWithMask, + white25x25, + black50x50) + self.assertRaises(Exception, image_tools._GetDifferenceWithMask, + white25x25, + white25x25, + mask=black50x50) + + def testCreateMask(self): + black25x25 = _GenImage((25, 25), (0, 0, 0)) + white25x25 = _GenImage((25, 25), (255, 255, 255)) + + m1 = image_tools.CreateMask([black25x25, white25x25]) + self.assertTrue(_AllPixelsOfColor(m1, (255, 255, 255))) + m2 = image_tools.CreateMask([black25x25, black25x25]) + self.assertTrue(_AllPixelsOfColor(m2, (0, 0, 0))) + m3 = image_tools.CreateMask([white25x25, white25x25]) + self.assertTrue(_AllPixelsOfColor(m3, (0, 0, 0))) + + def testTotalDifferentPixels(self): + white25x25 = _GenImage((25, 25), (255, 255, 255)) + white50x50 = _GenImage((50, 50), (255, 255, 255)) + black25x25 = _GenImage((25, 25), (0, 0, 0)) + + self.assertEquals(image_tools.TotalDifferentPixels(white25x25, + white25x25), + 0) + self.assertEquals(image_tools.TotalDifferentPixels(black25x25, + black25x25), + 0) + self.assertEquals(image_tools.TotalDifferentPixels(white25x25, + black25x25), + 25*25) + self.assertEquals(image_tools.TotalDifferentPixels(white25x25, + black25x25, + mask=white25x25), + 0) + self.assertEquals(image_tools.TotalDifferentPixels(white25x25, + white25x25, + mask=white25x25), + 0) + self.assertEquals(image_tools.TotalDifferentPixels(white25x25, + black25x25, + mask=black25x25), + 25*25) + self.assertEquals(image_tools.TotalDifferentPixels(white25x25, + white25x25, + mask=black25x25), + 0) + self.assertRaises(Exception, image_tools.TotalDifferentPixels, + white25x25, white50x50) + self.assertRaises(Exception, image_tools.TotalDifferentPixels, + white25x25, white25x25, mask=white50x50) + + def testSameImage(self): + white25x25 = _GenImage((25, 25), (255, 255, 255)) + black25x25 = _GenImage((25, 25), (0, 0, 0)) + white50x50 = _GenImage((50, 50), (255, 255, 255)) + + self.assertTrue(image_tools.SameImage(white25x25, white25x25)) + self.assertFalse(image_tools.SameImage(white25x25, black25x25)) + + self.assertTrue(image_tools.SameImage(white25x25, black25x25, + mask=white25x25)) + self.assertFalse(image_tools.SameImage(white25x25, black25x25, + mask=black25x25)) + self.assertTrue(image_tools.SameImage(black25x25, black25x25)) + self.assertTrue(image_tools.SameImage(black25x25, black25x25, + mask=white25x25)) + self.assertTrue(image_tools.SameImage(white25x25, white25x25, + mask=white25x25)) + self.assertRaises(Exception, image_tools.SameImage, + white25x25, white50x50) + self.assertRaises(Exception, image_tools.SameImage, + white25x25, white25x25, + mask=white50x50) + + def testVisualizeImageDifferences(self): + white25x25 = _GenImage((25, 25), (255, 255, 255)) + black25x25 = _GenImage((25, 25), (0, 0, 0)) + white50x50 = _GenImage((50, 50), (255, 255, 255)) + self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences( + white25x25, black25x25), (255, 255, 255))) + self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences( + white25x25, white25x25), (0, 0, 0))) + self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences( + black25x25, black25x25), (0, 0, 0))) + self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences( + white25x25, black25x25, mask=white25x25), (0, 0, 0))) + self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences( + white25x25, black25x25, mask=black25x25), (255, 255, 255))) + self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences( + white25x25, white25x25, mask=white25x25), (0, 0, 0))) + self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences( + white25x25, white25x25, mask=black25x25), (0, 0, 0))) + self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences( + black25x25, black25x25, mask=black25x25), (0, 0, 0))) + self.assertTrue(_AllPixelsOfColor(image_tools.VisualizeImageDifferences( + black25x25, black25x25, mask=white25x25), (0, 0, 0))) + + self.assertRaises(Exception, + image_tools.VisualizeImageDifferences, + white25x25, + white50x50) + self.assertRaises(Exception, + image_tools.VisualizeImageDifferences, + white25x25, + black25x25, + mask=white50x50) + + def testSerialization(self): + black25x25 = _GenImage((25, 25), (0, 0, 0)) + white25x25 = _GenImage((25, 25), (255, 255, 255)) + self.assertTrue(_AllPixelsOfColor( + image_tools.DeserializeImage( + image_tools.SerializeImage(white25x25)), (255, 255, 255))) + self.assertTrue(_AllPixelsOfColor( + image_tools.DeserializeImage( + image_tools.SerializeImage(black25x25)), (0, 0, 0))) + + +if __name__ == '__main__': + unittest.main() diff --git a/chrome/test/functional/webpagereplay.py b/chrome/test/functional/webpagereplay.py index 6e6685852d..6d2dc5ca74 100755 --- a/chrome/test/functional/webpagereplay.py +++ b/chrome/test/functional/webpagereplay.py @@ -35,6 +35,14 @@ def GetChromeFlags(replay_host, http_port, https_port): '--ignore-certificate-errors', ] +# Signal masks on Linux are inherited from parent processes. If anything +# invoking us accidentally masks SIGINT (e.g. by putting a process in the +# background from a shell script), sending a SIGINT to the child will fail +# to terminate it. Running this signal handler before execing should fix that +# problem. +def ResetInterruptHandler(): + signal.signal(signal.SIGINT, signal.SIG_DFL) + class ReplayError(Exception): """Catch-all exception for the module.""" pass @@ -127,7 +135,7 @@ class ReplayServer(object): def IsStarted(self): """Checks to see if the server is up and running.""" - for _ in range(10): + for _ in range(30): if self.replay_process.poll() is not None: # The process has exited. break @@ -153,8 +161,10 @@ class ReplayServer(object): cmd_line.append(self.archive_path) self.log_fh = self._OpenLogFile() logging.debug('Starting Web-Page-Replay: %s', cmd_line) - self.replay_process = subprocess.Popen( - cmd_line, stdout=self.log_fh, stderr=subprocess.STDOUT) + kwargs = { 'stdout': self.log_fh, 'stderr': subprocess.STDOUT } + if sys.platform.startswith('linux') or sys.platform == 'darwin': + kwargs['preexec_fn'] = ResetInterruptHandler + self.replay_process = subprocess.Popen(cmd_line, **kwargs) if not self.IsStarted(): log = open(self.log_path).read() raise ReplayNotStartedError( diff --git a/chrome/test/gpu/gpu_pixel_browsertest.cc b/chrome/test/gpu/gpu_pixel_browsertest.cc index e7c1c3c7b8..ed4e1ff0cb 100644 --- a/chrome/test/gpu/gpu_pixel_browsertest.cc +++ b/chrome/test/gpu/gpu_pixel_browsertest.cc @@ -268,7 +268,7 @@ class GpuPixelBrowserTest : public InProcessBrowserTest { LOG(ERROR) << "Can't save revision file to: " << rev_path.value(); rt = false; - file_util::Delete(img_path, false); + base::Delete(img_path, false); } else { LOG(INFO) << "Saved revision file to: " << rev_path.value(); @@ -447,7 +447,7 @@ class GpuPixelBrowserTest : public InProcessBrowserTest { } ref_img_revision_ = max_revision; for (size_t i = 0; i < outdated_revs.size(); ++i) - file_util::Delete(outdated_revs[i], false); + base::Delete(outdated_revs[i], false); } DISALLOW_COPY_AND_ASSIGN(GpuPixelBrowserTest); diff --git a/chrome/test/logging/win/log_file_printer.cc b/chrome/test/logging/win/log_file_printer.cc index f262f0c261..40385b9a74 100644 --- a/chrome/test/logging/win/log_file_printer.cc +++ b/chrome/test/logging/win/log_file_printer.cc @@ -18,7 +18,7 @@ #include "base/logging.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/test/logging/win/log_file_reader.h" namespace { diff --git a/chrome/test/logging/win/test_log_collector.cc b/chrome/test/logging/win/test_log_collector.cc index 86ee24c21d..4324e26f58 100644 --- a/chrome/test/logging/win/test_log_collector.cc +++ b/chrome/test/logging/win/test_log_collector.cc @@ -262,7 +262,7 @@ void TestLogCollector::ProcessSessionForTest( std::cerr.flush(); } - if (!file_util::Delete(log_file_, false)) + if (!base::Delete(log_file_, false)) LOG(ERROR) << "Failed to delete log file " << log_file_.value(); } diff --git a/chrome/test/mini_installer_test/installer_test_util.cc b/chrome/test/mini_installer_test/installer_test_util.cc index cb89e55564..2d8e2d52a8 100644 --- a/chrome/test/mini_installer_test/installer_test_util.cc +++ b/chrome/test/mini_installer_test/installer_test_util.cc @@ -62,7 +62,7 @@ bool DeleteInstallDirectory(bool system_level, if (!has_install_dir || !file_util::PathExists(path)) return false; path = path.AppendASCII(version); - return file_util::Delete(path, true); + return base::Delete(path, true); } bool DeleteRegistryKey(bool system_level, diff --git a/chrome/test/mini_installer_test/run_all_unittests.cc b/chrome/test/mini_installer_test/run_all_unittests.cc index 90e947ce0f..d4d69b04df 100644 --- a/chrome/test/mini_installer_test/run_all_unittests.cc +++ b/chrome/test/mini_installer_test/run_all_unittests.cc @@ -33,7 +33,7 @@ void BackUpProfile(bool chrome_frame) { // Will check if User Data is already backed up. // If yes, will delete and create new one. if (file_util::PathExists(backup_path)) - file_util::Delete(backup_path, true); + base::Delete(backup_path, true); file_util::CopyDirectory(path, backup_path, true); } else { printf("Chrome is not installed. Will not take any backup\n"); diff --git a/chrome/test/nacl/nacl_browsertest.cc b/chrome/test/nacl/nacl_browsertest.cc index dffa442f54..f8af44ca12 100644 --- a/chrome/test/nacl/nacl_browsertest.cc +++ b/chrome/test/nacl/nacl_browsertest.cc @@ -2,6 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stdio.h> +#if defined(OS_POSIX) +#include <unistd.h> +#elif defined(OS_WIN) +#include <windows.h> +#endif + +#define TELEMETRY 1 + #include "chrome/test/nacl/nacl_browsertest_util.h" namespace { @@ -19,6 +28,7 @@ namespace { #define MAYBE_CrossOriginFail DISABLED_CrossOriginFail #define MAYBE_SameOriginCookie DISABLED_SameOriginCookie #define MAYBE_CORSNoCookie DISABLED_CORSNoCookie +#define MAYBE_SysconfNprocessorsOnln DISABLED_SysconfNprocessorsOnln #else #define MAYBE_SimpleLoad SimpleLoad #define MAYBE_ExitStatus0 ExitStatus0 @@ -31,12 +41,27 @@ namespace { #define MAYBE_CrossOriginFail CrossOriginFail #define MAYBE_SameOriginCookie SameOriginCookie #define MAYBE_CORSNoCookie CORSNoCookie +# if defined(OS_WIN) +# define MAYBE_SysconfNprocessorsOnln DISABLED_SysconfNprocessorsOnln +# else +# define MAYBE_SysconfNprocessorsOnln SysconfNprocessorsOnln +# endif #endif NACL_BROWSER_TEST_F(NaClBrowserTest, MAYBE_SimpleLoad, { RunLoadTest(FILE_PATH_LITERAL("nacl_load_test.html")); }) +IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclWithNewCache, + MAYBE_PNACL(SimpleLoad)) { + RunLoadTest(FILE_PATH_LITERAL("nacl_load_test.html")); +} + +IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclWithNewCache, + MAYBE_PNACL(PnaclErrorHandling)) { + RunNaClIntegrationTest(FILE_PATH_LITERAL("pnacl_error_handling.html")); +} + NACL_BROWSER_TEST_F(NaClBrowserTest, MAYBE_ExitStatus0, { RunNaClIntegrationTest(FILE_PATH_LITERAL( "pm_exit_status_test.html?trigger=exit0&expected_exit=0")); @@ -64,6 +89,61 @@ NACL_BROWSER_TEST_F(NaClBrowserTest, MAYBE_PnaclMimeType, { RunLoadTest(FILE_PATH_LITERAL("pnacl_mime_type.html")); }) +// Some versions of Visual Studio does not like preprocessor +// conditionals inside the argument of a macro, so we put the +// conditionals on a helper function. We are already in an anonymous +// namespace, so the name of the helper is not visible in external +// scope. +#if defined(OS_POSIX) +base::FilePath::StringType NumberOfCoresAsFilePathString() { + char string_rep[23]; + long nprocessors = sysconf(_SC_NPROCESSORS_ONLN); +#if TELEMETRY + fprintf(stderr, "browser says nprocessors = %ld\n", nprocessors); + fflush(NULL); +#endif + snprintf(string_rep, sizeof string_rep, "%ld", nprocessors); + return string_rep; +} +#elif defined(OS_WIN) +base::FilePath::StringType NumberOfCoresAsFilePathString() { + wchar_t string_rep[23]; + SYSTEM_INFO system_info; + GetSystemInfo(&system_info); +#if TELEMETRY + fprintf(stderr, "browser says nprocessors = %d\n", + system_info.dwNumberOfProcessors); + fflush(NULL); +#endif + _snwprintf_s(string_rep, sizeof string_rep / sizeof string_rep[0], _TRUNCATE, + L"%u", system_info.dwNumberOfProcessors); + return string_rep; +} +#endif + +#if TELEMETRY +static void PathTelemetry(base::FilePath::StringType const &path) { +# if defined(OS_WIN) + fwprintf(stderr, L"path = %s\n", path.c_str()); +# else + fprintf(stderr, "path = %s\n", path.c_str()); +# endif + fflush(NULL); +} +#else +static void PathTelemetry(base::FilePath::StringType const &path) { + (void) path; +} +#endif + +NACL_BROWSER_TEST_F(NaClBrowserTest, MAYBE_SysconfNprocessorsOnln, { + base::FilePath::StringType path = + FILE_PATH_LITERAL("sysconf_nprocessors_onln_test.html?cpu_count="); + path = path + NumberOfCoresAsFilePathString(); + PathTelemetry(path); + RunNaClIntegrationTest(path); +}) + IN_PROC_BROWSER_TEST_F(NaClBrowserTestStatic, MAYBE_CrossOriginCORS) { RunLoadTest(FILE_PATH_LITERAL("cross_origin/cors.html")); } diff --git a/chrome/test/nacl/nacl_browsertest_util.cc b/chrome/test/nacl/nacl_browsertest_util.cc index 77136b73ae..41cf217a38 100644 --- a/chrome/test/nacl/nacl_browsertest_util.cc +++ b/chrome/test/nacl/nacl_browsertest_util.cc @@ -4,7 +4,9 @@ #include "chrome/test/nacl/nacl_browsertest_util.h" +#include <stdlib.h> #include "base/command_line.h" +#include "base/environment.h" #include "base/json/json_reader.h" #include "base/path_service.h" #include "base/values.h" @@ -18,7 +20,6 @@ #include "net/base/net_util.h" #include "webkit/plugins/webplugininfo.h" - typedef TestMessageHandler::MessageResponse MessageResponse; MessageResponse StructuredMessageHandler::HandleMessage( @@ -287,6 +288,11 @@ void NaClBrowserTestPnacl::SetUpCommandLine(CommandLine* command_line) { command_line->AppendSwitch(switches::kEnablePnacl); } +NaClBrowserTestPnaclWithNewCache::NaClBrowserTestPnaclWithNewCache() { + scoped_ptr<base::Environment> env(base::Environment::Create()); + env->SetVar("PNACL_USE_NEW_CACHE", "true"); +} + base::FilePath::StringType NaClBrowserTestStatic::Variant() { return FILE_PATH_LITERAL("static"); } diff --git a/chrome/test/nacl/nacl_browsertest_util.h b/chrome/test/nacl/nacl_browsertest_util.h index 3b9853f02f..914f6ebc49 100644 --- a/chrome/test/nacl/nacl_browsertest_util.h +++ b/chrome/test/nacl/nacl_browsertest_util.h @@ -123,6 +123,13 @@ class NaClBrowserTestPnacl : public NaClBrowserTestBase { virtual bool IsPnacl() OVERRIDE; }; +// Temporary class for running tests with the new cache enabled. Once all the +// pieces land, this will go away and the new cache will be on by default. +class NaClBrowserTestPnaclWithNewCache : public NaClBrowserTestPnacl { + public: + NaClBrowserTestPnaclWithNewCache(); +}; + // A NaCl browser test only using static files. class NaClBrowserTestStatic : public NaClBrowserTestBase { public: diff --git a/chrome/test/perf/feature_startup_test.cc b/chrome/test/perf/feature_startup_test.cc index 283c1ce295..d75e4d2d63 100644 --- a/chrome/test/perf/feature_startup_test.cc +++ b/chrome/test/perf/feature_startup_test.cc @@ -5,7 +5,7 @@ #include "base/path_service.h" #include "base/perftimer.h" #include "base/strings/stringprintf.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" diff --git a/chrome/test/perf/generate_profile.cc b/chrome/test/perf/generate_profile.cc index c8df76205b..b07f17421e 100644 --- a/chrome/test/perf/generate_profile.cc +++ b/chrome/test/perf/generate_profile.cc @@ -16,7 +16,7 @@ #include "base/process_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/browser/history/history_service.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/top_sites.h" @@ -256,7 +256,7 @@ bool GenerateProfile(GenerateProfileTypes types, base::FilePath path = file_iterator.Next(); while (!path.empty()) { base::FilePath dst_file = dst_dir.Append(path.BaseName()); - file_util::Delete(dst_file, false); + base::Delete(dst_file, false); if (!file_util::CopyFile(path, dst_file)) { PLOG(ERROR) << "Copying file failed"; return false; diff --git a/chrome/test/perf/memory_test.cc b/chrome/test/perf/memory_test.cc index fae4a8c584..af9564a938 100644 --- a/chrome/test/perf/memory_test.cc +++ b/chrome/test/perf/memory_test.cc @@ -39,7 +39,7 @@ class MemoryTest : public UIPerfTest { virtual ~MemoryTest() { // Cleanup our temporary directory. if (cleanup_temp_dir_on_exit_) - file_util::Delete(temp_dir_, true); + base::Delete(temp_dir_, true); } // Called from SetUp() to determine the user data dir to copy. diff --git a/chrome/test/perf/rendering/latency_tests.cc b/chrome/test/perf/rendering/latency_tests.cc deleted file mode 100644 index 0f61cd9724..0000000000 --- a/chrome/test/perf/rendering/latency_tests.cc +++ /dev/null @@ -1,757 +0,0 @@ -// Copyright (c) 2012 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 "base/command_line.h" -#include "base/file_util.h" -#include "base/memory/scoped_ptr.h" -#include "base/path_service.h" -#include "base/strings/string_number_conversions.h" -#include "base/strings/stringprintf.h" -#include "base/test/test_switches.h" -#include "base/test/trace_event_analyzer.h" -#include "base/threading/platform_thread.h" -#include "base/timer.h" -#include "base/version.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/tabs/tab_strip_model.h" -#include "chrome/common/chrome_paths.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/test/base/tracing.h" -#include "chrome/test/base/ui_test_utils.h" -#include "chrome/test/perf/browser_perf_test.h" -#include "chrome/test/perf/perf_test.h" -#include "content/public/browser/render_view_host.h" -#include "content/public/browser/web_contents.h" -#include "content/public/common/content_switches.h" -#include "content/public/test/browser_test_utils.h" -#include "gpu/config/gpu_test_config.h" -#include "net/base/net_util.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/public/web/WebInputEvent.h" - -#if defined(OS_WIN) -#include "base/win/windows_version.h" -#endif - -// Run with --vmodule=latency_tests=1 to print verbose latency info. - -// How is latency measured? -// -// The test injects mouse moves many times per frame from the browser via -// RenderWidgetHost. Each input has a unique x coordinate. When the javascript -// handler receives the input, it stores the coordinate for later use in the -// requestAnimationFrame callback. In RAF, the test paints using the x -// coordinate as a color (in software, it sets the color of a table; in webgl, -// it executes a glClearColor). Trace events emit the color when it is picked up -// by either UpdateRect for software or gles2_cmd_decoder/glClear for webgl. -// -// Each UpdateRect (software) or SwapBuffers (webgl) is considered to be a frame -// boundary that will be used to measure latency in number of frames. Starting -// from a frame boundary Y, the test first determines what mouse x coordinate -// was represented by the color at that frame boundary. Then, the test walks -// backward through the trace events to find the input event matching that -// x coordinate. Then, the test find the nearest frame boundary X to the input -// event (may be before or after). The number of frame boundaries is then -// counted between X and Y to determine the input latency. -// -// By injecting mouse moves many times per frame, we reduce flakiness in the -// finding of the nearest frame boundary. -// -// This test only measures the latency introduced by chrome code -- it does not -// measure latency introduced by mouse drivers or the GL driver or the OS window -// manager. The actual latency seen by a user is more than what is reported by -// this test. -// -// Current modes: -// - Software RAF -// - WebGL RAF -// - WebGL RAF with Compositor Thread - -namespace { - -using trace_analyzer::CountMatches; -using trace_analyzer::FindClosest; -using trace_analyzer::FindLastOf; -using trace_analyzer::RateStats; -using trace_analyzer::Query; -using trace_analyzer::TraceAnalyzer; -using trace_analyzer::TraceEvent; -using trace_analyzer::TraceEventVector; - -enum LatencyTestMode { - kWebGL, - kWebGLThread, - kSoftware -}; - -enum LatencyTestFlags { - kInputHeavy = 1 << 0, - kInputDirty = 1 << 1, - kRafHeavy = 1 << 2, - kPaintHeavy = 1 << 3 -}; - -const int kWebGLCanvasWidth = 10; -const int kNumFrames = 80; -const int kInputsPerFrame = 16; -// Magic number to identify certain glClear events. -const int kClearColorGreen = 137; -const int kMouseY = 5; - -// Don't analyze start frames that may be inaccurate. Latencies can be as high -// as 5 frames or so, so skip the first 6 frames to get more accurate results. -const int kIgnoreStartFrames = 6; -// Don't analyze end frames that may be inaccurate. -const int kIgnoreEndFrames = 4; -// Minimum frames to produce an answer. -const int kMinimumFramesForAnalysis = 5; - -class LatencyTest - : public BrowserPerfTest, - public ::testing::WithParamInterface<int> { - public: - explicit LatencyTest(LatencyTestMode mode) : - query_instant_(Query::EventPhaseIs(TRACE_EVENT_PHASE_INSTANT)), - // These queries are initialized in RunTest. - query_begin_swaps_(Query::Bool(false)), - query_end_swaps_(Query::Bool(false)), - query_inputs_(Query::Bool(false)), - query_blits_(Query::Bool(false)), - query_clears_(Query::Bool(false)), - mouse_x_(0), - tab_width_(0), - mode_(mode), - delay_time_us_(0), - num_frames_(0), - verbose_(false), - test_flags_(0), - use_gpu_(mode == kWebGL || mode == kWebGLThread) {} - - virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; - - std::vector<int> GetAllBehaviors(); - - // Run test with specified |behaviors|. - // |behaviors| is a list of combinations of LatencyTestFlags. - void RunTest(const std::vector<int>& behaviors); - - private: - void RunTestInternal(const std::string& test_url, - bool send_inputs, - int input_delay_us); - - double CalculateLatency(); - - std::string GetModeString() { - switch (mode_) { - case kWebGL: - return "webgl"; - case kWebGLThread: - return "webgl_thread"; - case kSoftware: - return "software"; - default: - NOTREACHED() << "invalid mode"; - return std::string(); - } - } - - std::string GetTraceName(int flags); - - std::string GetUrlModeString(int flags); - - std::string GetUrl(int flags); - - void GetMeanFrameTimeMicros(int* frame_time) const; - - void SendInput(); - - void PrintEvents(const TraceEventVector& events); - - // Path to html file. - base::FilePath test_path_; - - // Query INSTANT events. - Query query_instant_; - - // Query begin of "swaps" which is SwapBuffers for GL and UpdateRect for - // software. - Query query_begin_swaps_; - - // Query end of "swaps" which is SwapBuffers for GL and UpdateRect for - // software. - Query query_end_swaps_; - - // Query mouse input entry events in browser process (ForwardMouseEvent). - Query query_inputs_; - - // Query GL blits for the WebGL canvas -- represents the compositor consuming - // the WebGL contents for display. - Query query_blits_; - - // Query glClear calls with mouse coordinate as clear color. - Query query_clears_; - - // For searching trace data. - scoped_ptr<TraceAnalyzer> analyzer_; - - // Current mouse x coordinate for injecting events. - int mouse_x_; - - // Width of window containing our tab. - int tab_width_; - - // Timer for injecting mouse events periodically. - base::RepeatingTimer<LatencyTest> timer_; - - // Mode: webgl or software. - LatencyTestMode mode_; - - // Delay time for javascript test code. Typically 2 x frame duration. Used - // to spin-wait in the javascript input handler and requestAnimationFrame. - int delay_time_us_; - - // Number of frames to render from the html test code. - int num_frames_; - - // Map from test flags combination to the calculated mean latency. - std::map<int, double> latencies_; - - // Whether to print more verbose output. - bool verbose_; - - // Current test flags combination, determining the behavior of the test. - int test_flags_; - - bool use_gpu_; -}; - -void LatencyTest::SetUpCommandLine(CommandLine* command_line) { - BrowserPerfTest::SetUpCommandLine(command_line); - if (mode_ == kWebGLThread) { - ASSERT_TRUE(use_gpu_); - command_line->AppendSwitch(switches::kEnableThreadedCompositing); - } else { - command_line->AppendSwitch(switches::kDisableThreadedCompositing); - } - if (!use_gpu_) - command_line->AppendSwitch(switches::kDisableAcceleratedCompositing); - command_line->AppendSwitch(switches::kDisableBackgroundNetworking); -} - -std::vector<int> LatencyTest::GetAllBehaviors() { - std::vector<int> behaviors; - int max_behaviors = kInputHeavy | kInputDirty | kRafHeavy | kPaintHeavy; - for (int i = 0; i <= max_behaviors; ++i) - behaviors.push_back(i); - return behaviors; -} - -void LatencyTest::RunTest(const std::vector<int>& behaviors) { - verbose_ = (logging::GetVlogLevel("latency_tests") > 0); - - // Linux Intel uses mesa driver, where multisampling is not supported. - // Multisampling is also not supported on virtualized mac os. - // The latency test uses the multisampling blit trace event to determine when - // the compositor is consuming the webgl context, so it currently doesn't work - // without multisampling. Since the Latency test does not depend much on the - // GPU, let's just skip testing on Intel since the data is redundant with - // other non-Intel bots. - gpu::GPUTestBotConfig test_bot; - test_bot.LoadCurrentConfig(NULL); - const std::vector<uint32>& gpu_vendor = test_bot.gpu_vendor(); -#if defined(OS_LINUX) - if (gpu_vendor.size() == 1 && gpu_vendor[0] == 0x8086) - return; -#endif // defined(OS_LINUX) -#if defined(OS_MACOSX) - if (gpu_vendor.size() == 1 && gpu_vendor[0] == 0x15AD) - return; -#endif // defined(OS_MACOSX) - -#if defined(OS_WIN) - // Latency test doesn't work on WinXP. crbug.com/128066 - if (base::win::OSInfo::GetInstance()->version() == base::win::VERSION_XP) - return; -#endif - - // Construct queries for searching trace events via TraceAnalyzer. - if (use_gpu_) { - query_begin_swaps_ = query_instant_ && - Query::EventNameIs("SwapBuffersLatency") && - Query::EventArg("width") != Query::Int(kWebGLCanvasWidth); - query_end_swaps_ = query_instant_ && - Query::EventNameIs("CompositorSwapBuffersComplete"); - } else if (mode_ == kSoftware) { - // Software updates need to have x=0 and y=0 to contain the input color. - query_begin_swaps_ = query_instant_ && - Query::EventNameIs("UpdateRect") && - Query::EventArg("x+y") == Query::Int(0); - query_end_swaps_ = query_instant_ && - Query::EventNameIs("UpdateRectComplete") && - Query::EventArg("x+y") == Query::Int(0); - } - query_inputs_ = query_instant_ && - Query::EventNameIs("MouseEventBegin"); - query_blits_ = query_instant_ && - Query::EventNameIs("DoBlit") && - Query::EventArg("width") == Query::Int(kWebGLCanvasWidth); - query_clears_ = query_instant_ && - Query::EventNameIs("DoClear") && - Query::EventArg("green") == Query::Int(kClearColorGreen); - Query query_width_swaps = Query::Bool(false); - if (use_gpu_) { - query_width_swaps = query_begin_swaps_; - } else if (mode_ == kSoftware) { - query_width_swaps = query_instant_ && - Query::EventNameIs("UpdateRectWidth") && - Query::EventArg("width") > Query::Int(kWebGLCanvasWidth); - } - - // Set path to test html. - ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_path_)); - test_path_ = test_path_.Append(FILE_PATH_LITERAL("perf")); - test_path_ = test_path_.Append(FILE_PATH_LITERAL("latency_suite.html")); - ASSERT_TRUE(file_util::PathExists(test_path_)) - << "Missing test file: " << test_path_.value(); - - // Run once with defaults to measure the frame times. - delay_time_us_ = 0; - // kNumFrames may be very high, but we only need a few frames to measure - // average frame times. - num_frames_ = 30; - int initial_flags = 0; - if (mode_ == kSoftware) { - // For the first run, run software with kPaintHeavy (which toggles the - // background color every frame) to force an update each RAF. Otherwise it - // won't trigger an UpdateRect each frame and we won't be able to measure - // framerate, because there are no inputs during the first run. - initial_flags = static_cast<int>(kPaintHeavy); - } - RunTestInternal(GetUrl(initial_flags), false, 0); - - // Get width of tab so that we know the limit of x coordinates for the - // injected mouse inputs. - const TraceEvent* swap_event = analyzer_->FindFirstOf(query_width_swaps); - ASSERT_TRUE(swap_event); - tab_width_ = swap_event->GetKnownArgAsInt("width"); - // Keep printf output clean by limiting input coords to three digits: - tab_width_ = (tab_width_ < 1000) ? tab_width_ : 999; - // Sanity check the tab_width -- it should be more than 100 pixels. - EXPECT_GT(tab_width_, 100); - - int mean_frame_time_us = 0; - GetMeanFrameTimeMicros(&mean_frame_time_us); - if (verbose_) - printf("Mean frame time micros = %d\n", mean_frame_time_us); - // Delay time is 2x the average frame time. - delay_time_us_ = 2 * mean_frame_time_us; - // Calculate delay time between inputs based on the measured frame time. - // This prevents flooding the browser with more events than we need if the - // test is running very slow (such as on a VM). - int delay_us = mean_frame_time_us / kInputsPerFrame; - - // Reset num_frames_ for actual test runs. - num_frames_ = kNumFrames; - - // Run input latency test with each requested behavior. - for (size_t i = 0; i < behaviors.size(); ++i) { - test_flags_ = behaviors[i]; - std::string url = GetUrl(test_flags_); - printf("=============================================================\n"); - if (verbose_) - printf("Mode: %s\n", GetUrlModeString(i).c_str()); - printf("URL: %s\n", url.c_str()); - - // Do the actual test with input events. - RunTestInternal(url, true, delay_us); - latencies_[test_flags_] = CalculateLatency(); - - if (mode_ == kWebGLThread) { - // Print vsync info when in threaded mode. - Query query_vsync = - Query::EventNameIs("OutputSurface::OnVSyncParametersChanged") && - Query::EventHasNumberArg("timebase") && - Query::EventHasNumberArg("interval"); - - const TraceEvent* vsync_info = analyzer_->FindFirstOf(query_vsync); - if (vsync_info) { - double timebase = vsync_info->GetKnownArgAsDouble("timebase"); - double interval = vsync_info->GetKnownArgAsDouble("interval"); - printf("VSync scheduling: timebase = %f; interval = %f\n", - timebase, interval); - } - } - } - - // Print summary if more than 1 behavior was tested in this run. This is only - // for manual test runs for human reabable results, not for perf bots. - if (behaviors.size() > 1) { - printf("#############################################################\n"); - printf("## %s\n", GetModeString().c_str()); - if (verbose_) { - printf("Latency, behavior:\n"); - for (size_t i = 0; i < behaviors.size(); ++i) { - printf("%.1f, %s%s%s%s\n", latencies_[behaviors[i]], - (i & kInputHeavy) ? "InputHeavy " : "", - (i & kInputDirty) ? "InputDirty " : "", - (i & kRafHeavy) ? "RafHeavy " : "", - (i & kPaintHeavy) ? "PaintHeavy " : ""); - } - } - printf("Latencies for tests: "); - for (size_t i = 0; i < behaviors.size(); ++i) { - printf("%.1f%s", latencies_[behaviors[i]], - (i < behaviors.size() - 1) ? ", " : ""); - } - printf("\n"); - printf("#############################################################\n"); - } -} - -void LatencyTest::RunTestInternal(const std::string& test_url, - bool send_inputs, - int input_delay_us) { - mouse_x_ = 0; - - ASSERT_TRUE(tracing::BeginTracing("cc,test_gpu,test_latency")); - - ui_test_utils::NavigateToURLWithDisposition( - browser(), GURL(test_url), CURRENT_TAB, - ui_test_utils::BROWSER_TEST_NONE); - - // Start sending mouse inputs. - if (send_inputs) { - // Round input_delay_us down to nearest milliseconds. The rounding in timer - // code rounds up from us to ms, so we need to do our own rounding here. - int input_delay_ms = input_delay_us / 1000; - input_delay_ms = (input_delay_ms <= 0) ? 1 : input_delay_ms; - timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(input_delay_ms), - this, &LatencyTest::SendInput); - } - - // Wait for message indicating the test has finished running. - content::DOMMessageQueue message_queue; - ASSERT_TRUE(message_queue.WaitForMessage(NULL)); - - timer_.Stop(); - - std::string json_events; - ASSERT_TRUE(tracing::EndTracing(&json_events)); - - analyzer_.reset(TraceAnalyzer::Create(json_events)); - analyzer_->AssociateBeginEndEvents(); - analyzer_->MergeAssociatedEventArgs(); -} - -double LatencyTest::CalculateLatency() { - TraceEventVector events; - if (use_gpu_) { - // Search for three types of events in WebGL mode: - // - onscreen swaps. - // - DoClear calls that contain the mouse x coordinate. - // - mouse events. - analyzer_->FindEvents(query_begin_swaps_ || query_end_swaps_ || - query_inputs_ || query_blits_ || query_clears_, - &events); - } else if (mode_ == kSoftware) { - analyzer_->FindEvents(query_begin_swaps_ || query_end_swaps_ || - query_inputs_, &events); - } else { - NOTREACHED() << "invalid mode"; - } - - if (verbose_) - PrintEvents(events); - - int swap_count = 0; - size_t previous_blit_pos = 0; - swap_count = 0; - std::vector<double> latencies; - printf("Measured latency (in number of frames) for each frame:\n"); - for (size_t i = 0; i < events.size(); ++i) { - if (query_end_swaps_.Evaluate(*events[i])) { - size_t end_swap_pos = i; - - // Compositor context swap buffers. - ++swap_count; - // Don't analyze first few swaps, because they are filling the rendering - // pipeline and may be unstable. - if (swap_count > kIgnoreStartFrames) { - // First, find the beginning of this swap. - size_t begin_swap_pos = 0; - EXPECT_TRUE(FindLastOf(events, query_begin_swaps_, end_swap_pos, - &begin_swap_pos)); - - int mouse_x = 0; - if (use_gpu_) { - // Trace backwards through the events to find the input event that - // matches the glClear that was presented by this SwapBuffers. - - // Step 1: Find the last blit (which will be the WebGL blit). - size_t blit_pos = 0; - EXPECT_TRUE(FindLastOf(events, query_blits_, begin_swap_pos, - &blit_pos)); - // Skip this SwapBuffers if the blit has already been consumed by a - // previous SwapBuffers. This means the current frame did not receive - // an update from WebGL. - if (blit_pos == previous_blit_pos) { - if (verbose_) - printf(" %03d: MISS_BLIT\n", swap_count); - else - printf(" MISS_BLIT"); - continue; - } - previous_blit_pos = blit_pos; - - // Step 2: find the last clear from the WebGL blit. This will be the - // value of the latest mouse input that has affected this swap. - size_t clear_pos = 0; - EXPECT_TRUE(FindLastOf(events, query_clears_, blit_pos, &clear_pos)); - mouse_x = events[clear_pos]->GetKnownArgAsInt("red"); - } else if (mode_ == kSoftware) { - // The software path gets the mouse_x directly from the DIB colors. - mouse_x = events[begin_swap_pos]->GetKnownArgAsInt("color"); - } - - // Find the corresponding mouse input. - size_t input_pos = 0; - Query query_mouse_event = query_inputs_ && - Query::EventArg("x") == Query::Int(mouse_x); - EXPECT_TRUE(FindLastOf(events, query_mouse_event, begin_swap_pos, - &input_pos)); - - // Step 4: Find the nearest onscreen SwapBuffers to this input event. - size_t end_swap_left = 0; - size_t end_swap_right = 0; - EXPECT_TRUE(FindLastOf(events, query_end_swaps_, input_pos, - &end_swap_left)); - EXPECT_TRUE(FindFirstOf(events, query_end_swaps_, input_pos, - &end_swap_right)); - - EXPECT_LT(end_swap_left, input_pos); - EXPECT_LT(end_swap_left, end_swap_right); - EXPECT_LT(input_pos, end_swap_right); - - // Calculate the fraction of the first frame from the input event to the - // next end_swap event: (right_swap - left_swap) / (right_swap - input). - double frame_time = (events[end_swap_right]->timestamp - - events[end_swap_left]->timestamp); - double input_time = (events[end_swap_right]->timestamp - - events[input_pos]->timestamp); - double latency_frame_fraction = input_time / frame_time; - - EXPECT_LE(latency_frame_fraction, 1.0); - - // Calculate latency by counting the number of swaps between the input - // event and the corresponding on-screen end-of-swap. - int latency_int = CountMatches(events, query_end_swaps_, - input_pos, end_swap_pos); - - double latency_frames = static_cast<double>(latency_int) + - latency_frame_fraction; - latencies.push_back(latency_frames); - if (verbose_) - printf(" %03d: %0.1f (int %d, frac %f)\n", swap_count, latency_frames, - latency_int, latency_frame_fraction); - else - printf(" %0.1f", latency_frames); - } - } - } - printf("\n"); - - size_t ignoreEndFrames = static_cast<size_t>(kIgnoreEndFrames); - bool haveEnoughFrames = latencies.size() > - ignoreEndFrames + static_cast<size_t>(kMinimumFramesForAnalysis); - EXPECT_TRUE(haveEnoughFrames); - if (!haveEnoughFrames) - return 0.0; - - double mean_latency = 0.0; - // Skip last few frames, because they may be unreliable. - size_t num_consider = latencies.size() - ignoreEndFrames; - for (size_t i = 0; i < num_consider; ++i) - mean_latency += latencies[i]; - mean_latency /= static_cast<double>(num_consider); - printf("Mean latency = %f\n", mean_latency); - - double mean_error = 0.0; - for (size_t i = 0; i < num_consider; ++i) { - double offset = fabs(mean_latency - latencies[i]); - mean_error = (offset > mean_error) ? offset : mean_error; - } - - std::string trace_name = GetTraceName(test_flags_); - std::string mean_and_error = base::StringPrintf("%f,%f", mean_latency, - mean_error); - perf_test::PrintResultMeanAndError(GetModeString(), - std::string(), - trace_name, - mean_and_error, - "frames", - true); - return mean_latency; -} - -std::string LatencyTest::GetTraceName(int flags) { - if (flags == 0) - return "simple"; - std::string name; - if (flags & kInputHeavy) - name += "ih"; - if (flags & kInputDirty) - name += std::string(name.empty()? "" : "_") + "id"; - if (flags & kRafHeavy) - name += std::string(name.empty()? "" : "_") + "rh"; - if (flags & kPaintHeavy) - name += std::string(name.empty()? "" : "_") + "ph"; - return name; -} - -std::string LatencyTest::GetUrlModeString(int flags) { - std::string mode = "&mode=" + GetModeString(); - if (flags & kInputHeavy) - mode += "&inputHeavy"; - if (flags & kInputDirty) - mode += "&inputDirty"; - if (flags & kRafHeavy) - mode += "&rafHeavy"; - if (flags & kPaintHeavy) - mode += "&paintHeavy"; - return mode; -} - -std::string LatencyTest::GetUrl(int flags) { - std::string test_url = - net::FilePathToFileURL(test_path_).possibly_invalid_spec(); - test_url += "?numFrames=" + base::IntToString(num_frames_); - test_url += "&canvasWidth=" + base::IntToString(kWebGLCanvasWidth); - test_url += "&clearColorGreen=" + base::IntToString(kClearColorGreen); - test_url += "&delayTimeMS=" + base::IntToString(delay_time_us_ / 1000); - test_url += "&y=" + base::IntToString(kMouseY); - return test_url + GetUrlModeString(flags); -} - -void LatencyTest::GetMeanFrameTimeMicros(int* frame_time) const { - TraceEventVector events; - // Search for compositor swaps (or UpdateRects in the software path). - analyzer_->FindEvents(query_end_swaps_, &events); - RateStats stats; - trace_analyzer::RateStatsOptions options; - options.trim_max = 3; - options.trim_min = 3; - ASSERT_TRUE(GetRateStats(events, &stats, &options)); - - // Check that the number of swaps is close to kNumFrames. - EXPECT_LT(num_frames_ - num_frames_ / 4, static_cast<int>(events.size())); - *frame_time = static_cast<int>(stats.mean_us); -} - -void LatencyTest::SendInput() { - content::RenderViewHost* rvh = - browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); - WebKit::WebMouseEvent mouse_event; - mouse_event.movementX = 1; - mouse_x_ += mouse_event.movementX; - // Wrap mouse_x_ when it's near the edge of the tab. - if (mouse_x_ > tab_width_ - 5) - mouse_x_ = 1; - mouse_event.x = mouse_event.windowX = mouse_x_; - // Set y coordinate to be a few pixels down from the top of the window, - // so that it is between the top and bottom of the canvas. - mouse_event.y = mouse_event.windowY = 5; - mouse_event.type = WebKit::WebInputEvent::MouseMove; - TRACE_EVENT_INSTANT1("test_latency", "MouseEventBegin", - TRACE_EVENT_SCOPE_THREAD, "x", mouse_x_); - rvh->ForwardMouseEvent(mouse_event); -} - -void LatencyTest::PrintEvents(const TraceEventVector& events) { - bool is_software = (mode_ == kSoftware); - int swap_count = 0; - for (size_t i = 0; i < events.size(); ++i) { - if (events[i]->name == "MouseEventBegin") { - printf("%03d ", events[i]->GetKnownArgAsInt("x")); - } else if (events[i]->name == "DoClear") { - printf("Clr%03d ", events[i]->GetKnownArgAsInt("red")); - } else if (events[i]->name == "DoBlit") { - // WebGL context swap buffers. - printf("BLT "); - } else if (events[i]->name == "SwapBuffersLatency") { - // Compositor context swap buffers. - ++swap_count; - printf("|\nframe %03d: ", swap_count + 1); - } else if (is_software && events[i]->name == "UpdateRect") { - ++swap_count; - printf("(%d)|\nframe %03d: ", - events[i]->GetKnownArgAsInt("color"), swap_count + 1); - } - } - printf("\n"); -} - -// For running tests on GPU: -class LatencyTestWebGL : public LatencyTest { - public: - LatencyTestWebGL() : LatencyTest(kWebGL) {} -}; - -// For running tests on GPU with the compositor thread: -class LatencyTestWebGLThread : public LatencyTest { - public: - LatencyTestWebGLThread() : LatencyTest(kWebGLThread) {} -}; - -// For running tests on Software: -class LatencyTestSW : public LatencyTest { - public: - LatencyTestSW() : LatencyTest(kSoftware) {} -}; - -//////////////////////////////////////////////////////////////////////////////// -/// Tests - -using ::testing::Values; - -// For manual testing only, run all input latency tests and print summary. -IN_PROC_BROWSER_TEST_F(LatencyTestWebGL, DISABLED_LatencyWebGLAll) { - RunTest(GetAllBehaviors()); -} - -// For manual testing only, run all input latency tests and print summary. -IN_PROC_BROWSER_TEST_F(LatencyTestWebGLThread, DISABLED_LatencyWebGLThreadAll) { - RunTest(GetAllBehaviors()); -} - -// For manual testing only, run all input latency tests and print summary. -IN_PROC_BROWSER_TEST_F(LatencyTestSW, DISABLED_LatencySoftwareAll) { - RunTest(GetAllBehaviors()); -} - -IN_PROC_BROWSER_TEST_P(LatencyTestWebGL, LatencyWebGL) { - RunTest(std::vector<int>(1, GetParam())); -} - -IN_PROC_BROWSER_TEST_P(LatencyTestWebGLThread, LatencyWebGLThread) { - RunTest(std::vector<int>(1, GetParam())); -} - -IN_PROC_BROWSER_TEST_P(LatencyTestSW, LatencySoftware) { - RunTest(std::vector<int>(1, GetParam())); -} - -#define LATENCY_SUITE_MODES() ::testing::Values( \ - 0, \ - kInputHeavy, \ - kInputHeavy | kInputDirty | kRafHeavy, \ - kInputHeavy | kInputDirty | kRafHeavy | kPaintHeavy, \ - kInputDirty | kPaintHeavy, \ - kInputDirty | kRafHeavy | kPaintHeavy) - -INSTANTIATE_TEST_CASE_P(, LatencyTestWebGL, LATENCY_SUITE_MODES()); -INSTANTIATE_TEST_CASE_P(, LatencyTestWebGLThread, LATENCY_SUITE_MODES()); -INSTANTIATE_TEST_CASE_P(, LatencyTestSW, LATENCY_SUITE_MODES()); - -} // namespace diff --git a/chrome/test/perf/shutdown_test.cc b/chrome/test/perf/shutdown_test.cc index df5bb3e0b3..a078833717 100644 --- a/chrome/test/perf/shutdown_test.cc +++ b/chrome/test/perf/shutdown_test.cc @@ -8,7 +8,7 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" #include "base/sys_info.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/env_vars.h" diff --git a/chrome/test/perf/startup_test.cc b/chrome/test/perf/startup_test.cc index 6ff4a2a0eb..72b39d2e1b 100644 --- a/chrome/test/perf/startup_test.cc +++ b/chrome/test/perf/startup_test.cc @@ -14,7 +14,7 @@ #include "base/sys_info.h" #include "base/test/test_file_util.h" #include "base/test/test_timeouts.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" diff --git a/chrome/test/perf/tab_switching_test.cc b/chrome/test/perf/tab_switching_test.cc index d3dd4e4deb..6d5859fa05 100644 --- a/chrome/test/perf/tab_switching_test.cc +++ b/chrome/test/perf/tab_switching_test.cc @@ -11,7 +11,7 @@ #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "base/threading/platform_thread.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" diff --git a/chrome/test/ppapi/ppapi_browsertest.cc b/chrome/test/ppapi/ppapi_browsertest.cc index 1074334f40..a036cb9a6c 100644 --- a/chrome/test/ppapi/ppapi_browsertest.cc +++ b/chrome/test/ppapi/ppapi_browsertest.cc @@ -215,6 +215,10 @@ TEST_PPAPI_IN_PROCESS(Core) TEST_PPAPI_OUT_OF_PROCESS(Core) TEST_PPAPI_NACL(Core) +TEST_PPAPI_IN_PROCESS(TraceEvent) +TEST_PPAPI_OUT_OF_PROCESS(TraceEvent) +TEST_PPAPI_NACL(TraceEvent) + TEST_PPAPI_IN_PROCESS(InputEvent) TEST_PPAPI_OUT_OF_PROCESS(InputEvent) TEST_PPAPI_NACL(InputEvent) @@ -802,10 +806,42 @@ IN_PROC_BROWSER_TEST_F(PPAPINaClPNaClTest, FileIO) { ); } -TEST_PPAPI_IN_PROCESS_VIA_HTTP(FileRef) +IN_PROC_BROWSER_TEST_F(PPAPITest, FileRef) { + RunTestViaHTTP( + LIST_TEST(FileRef_Create) + LIST_TEST(FileRef_GetFileSystemType) + LIST_TEST(FileRef_GetName) + LIST_TEST(FileRef_GetPath) + LIST_TEST(FileRef_GetParent) + LIST_TEST(FileRef_MakeDirectory) + LIST_TEST(FileRef_QueryAndTouchFile) + LIST_TEST(FileRef_DeleteFileAndDirectory) + LIST_TEST(FileRef_RenameFileAndDirectory) + // TODO(teravest): Add in-process support. + // LIST_TEST(FileRef_Query) + LIST_TEST(FileRef_FileNameEscaping) + // TODO(teravest): Add in-process support. + // LIST_TEST(FileRef_ReadDirectoryEntries) + ); +} // OutOfProcessPPAPITest.FileRef times out fairly often. // http://crbug.com/241646 -TEST_PPAPI_OUT_OF_PROCESS_VIA_HTTP(DISABLED_FileRef) +IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, FileRef) { + RunTestViaHTTP( + LIST_TEST(FileRef_Create) + LIST_TEST(FileRef_GetFileSystemType) + LIST_TEST(FileRef_GetName) + LIST_TEST(FileRef_GetPath) + LIST_TEST(FileRef_GetParent) + LIST_TEST(FileRef_MakeDirectory) + LIST_TEST(FileRef_QueryAndTouchFile) + LIST_TEST(FileRef_DeleteFileAndDirectory) + LIST_TEST(FileRef_RenameFileAndDirectory) + LIST_TEST(FileRef_Query) + LIST_TEST(FileRef_FileNameEscaping) + LIST_TEST(DISABLED_FileRef_ReadDirectoryEntries) + ); +} IN_PROC_BROWSER_TEST_F(PPAPINaClNewlibTest, FileRef) { RunTestViaHTTP( LIST_TEST(FileRef_Create) @@ -1396,12 +1432,18 @@ TEST_PPAPI_IN_PROCESS(MouseCursor) TEST_PPAPI_OUT_OF_PROCESS(MouseCursor) TEST_PPAPI_NACL(MouseCursor) +// PPB_NetworkProxy is not supported in-process. +TEST_PPAPI_OUT_OF_PROCESS(NetworkProxy) +TEST_PPAPI_NACL(NetworkProxy) + TEST_PPAPI_OUT_OF_PROCESS(TrueTypeFont) TEST_PPAPI_NACL(TrueTypeFont) -TEST_PPAPI_OUT_OF_PROCESS(VideoSource) - TEST_PPAPI_OUT_OF_PROCESS(VideoDestination) +TEST_PPAPI_NACL(VideoDestination) + +TEST_PPAPI_OUT_OF_PROCESS(VideoSource) +TEST_PPAPI_NACL(VideoSource) // PPB_Printing only implemented for out of process. TEST_PPAPI_OUT_OF_PROCESS(Printing) diff --git a/chrome/test/ppapi/ppapi_test.cc b/chrome/test/ppapi/ppapi_test.cc index 1a9b5db480..daed946469 100644 --- a/chrome/test/ppapi/ppapi_test.cc +++ b/chrome/test/ppapi/ppapi_test.cc @@ -317,6 +317,7 @@ OutOfProcessPPAPITest::OutOfProcessPPAPITest() { void OutOfProcessPPAPITest::SetUpCommandLine(CommandLine* command_line) { PPAPITest::SetUpCommandLine(command_line); command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); + command_line->AppendSwitch(switches::kUseFakeUIForMediaStream); } void PPAPINaClTest::SetUpCommandLine(CommandLine* command_line) { @@ -331,6 +332,7 @@ void PPAPINaClTest::SetUpCommandLine(CommandLine* command_line) { command_line->AppendSwitch(switches::kEnablePnacl); command_line->AppendSwitchASCII(switches::kAllowNaClSocketAPI, "127.0.0.1"); command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); + command_line->AppendSwitch(switches::kUseFakeUIForMediaStream); } // Append the correct mode and testcase string diff --git a/chrome/test/pyautolib/dom_mutation_observer.js b/chrome/test/pyautolib/dom_mutation_observer.js index cac49345f8..ced5ec3f02 100644 --- a/chrome/test/pyautolib/dom_mutation_observer.js +++ b/chrome/test/pyautolib/dom_mutation_observer.js @@ -175,7 +175,7 @@ function(automation_id, observer_id, observer_type, xpath, attribute, return; } - var obs = new WebKitMutationObserver(addNodeCallback); + var obs = new MutationObserver(addNodeCallback); obs.observe(document, { childList: true, attributes: true, @@ -196,7 +196,7 @@ function(automation_id, observer_id, observer_type, xpath, attribute, return; } - var obs = new WebKitMutationObserver(removeNodeCallback); + var obs = new MutationObserver(removeNodeCallback); obs.observe(document, { childList: true, attributes: true, @@ -219,7 +219,7 @@ function(automation_id, observer_id, observer_type, xpath, attribute, } window.domAutomationController.send("success"); - var obs = new WebKitMutationObserver(changeNodeCallback); + var obs = new MutationObserver(changeNodeCallback); obs.observe(node, { childList: true, attributes: true, @@ -240,7 +240,7 @@ function(automation_id, observer_id, observer_type, xpath, attribute, return; } - var obs = new WebKitMutationObserver(existsNodeCallback); + var obs = new MutationObserver(existsNodeCallback); obs.observe(document, { childList: true, attributes: true, diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py index 9ca0a4aee4..29b2e299eb 100755 --- a/chrome/test/pyautolib/pyauto.py +++ b/chrome/test/pyautolib/pyauto.py @@ -288,8 +288,9 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): '--skip-oauth-login', # Enables injection of test content script for webui login automation '--auth-ext-path=%s' % auth_ext_path, - # Enable automation provider and chromeos net logs - '--vmodule=*/browser/automation/*=2,*/chromeos/net/*=2', + # Enable automation provider, chromeos net and chromeos login logs + '--vmodule=*/browser/automation/*=2,*/chromeos/net/*=2,' + + '*/chromeos/login/*=2', ] else: return [] @@ -2995,33 +2996,6 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): finally: shutil.rmtree(tempdir, ignore_errors=True) - def ImportSettings(self, import_from, import_items, windex=0): - """Import the specified import items from the specified browser. - - Implements the features available in the "Import Settings" part of the - first-run UI dialog. - - Args: - import_from: A string indicating which browser to import from. Possible - strings (depending on which browsers are installed on the - machine) are: 'Mozilla Firefox', 'Google Toolbar', - 'Microsoft Internet Explorer', 'Safari' - import_items: A list of strings indicating which items to import. - Strings that can be in the list are: - HISTORY, FAVORITES, PASSWORDS, SEARCH_ENGINES, HOME_PAGE, - ALL (note: COOKIES is not supported by the browser yet) - windex: window index, defaults to 0. - - Raises: - pyauto_errors.JSONInterfaceError if the automation call returns an error. - """ - cmd_dict = { # Prepare command for the json interface - 'command': 'ImportSettings', - 'import_from': import_from, - 'import_items': import_items - } - return self._GetResultFromJSONRequest(cmd_dict, windex=windex) - def AddSavedPassword(self, password_dict, windex=0): """Adds the given username-password combination to the saved passwords. diff --git a/chrome/test/pyautolib/pyautolib.cc b/chrome/test/pyautolib/pyautolib.cc index 69b57232fd..3e27fb931c 100644 --- a/chrome/test/pyautolib/pyautolib.cc +++ b/chrome/test/pyautolib/pyautolib.cc @@ -10,7 +10,7 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" -#include "base/time.h" +#include "base/time/time.h" #include "base/values.h" #include "chrome/common/automation_messages.h" #include "chrome/common/chrome_switches.h" diff --git a/chrome/test/pyautolib/pyautolib.h b/chrome/test/pyautolib/pyautolib.h index bcbe374e80..2b37dfc159 100644 --- a/chrome/test/pyautolib/pyautolib.h +++ b/chrome/test/pyautolib/pyautolib.h @@ -11,7 +11,7 @@ #include "base/compiler_specific.h" #include "base/message_loop.h" #include "base/test/test_timeouts.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/test/ui/ui_test.h" #include "chrome/test/ui/ui_test_suite.h" diff --git a/chrome/test/reliability/automated_ui_tests.cc b/chrome/test/reliability/automated_ui_tests.cc index 97d469f903..10a0c2a2f7 100644 --- a/chrome/test/reliability/automated_ui_tests.cc +++ b/chrome/test/reliability/automated_ui_tests.cc @@ -21,11 +21,12 @@ #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/threading/platform_thread.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/character_encoding.h" #include "chrome/browser/ui/view_ids.h" +#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_version_info.h" #include "chrome/common/env_vars.h" #include "chrome/common/url_constants.h" @@ -35,7 +36,6 @@ #include "chrome/test/automation/window_proxy.h" #include "chrome/test/reliability/automated_ui_tests.h" #include "chrome/test/ui/ui_test.h" -#include "components/breakpad/common/breakpad_paths.h" #include "googleurl/src/gurl.h" #include "ui/base/keycodes/keyboard_codes.h" @@ -767,7 +767,7 @@ void AutomatedUITest::LogInfoMessage(const std::string& info) { base::FilePath AutomatedUITest::GetMostRecentCrashDump() { base::FilePath crash_dump_path; base::FilePath most_recent_file_name; - PathService::Get(breakpad::DIR_CRASH_DUMPS, &crash_dump_path); + PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); base::Time most_recent_file_time; bool first_file = true; diff --git a/chrome/test/reliability/page_load_test.cc b/chrome/test/reliability/page_load_test.cc index f8ad018a3e..ddbf6eb155 100644 --- a/chrome/test/reliability/page_load_test.cc +++ b/chrome/test/reliability/page_load_test.cc @@ -53,7 +53,7 @@ #include "base/strings/string_util.h" #include "base/test/test_file_util.h" #include "base/threading/platform_thread.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/prefs/pref_service_mock_builder.h" #include "chrome/common/automation_messages.h" @@ -70,7 +70,6 @@ #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/automation/window_proxy.h" #include "chrome/test/ui/ui_test.h" -#include "components/breakpad/common/breakpad_paths.h" #include "net/base/net_util.h" #include "ui/base/keycodes/keyboard_codes.h" #include "v8/include/v8-testing.h" @@ -635,7 +634,7 @@ class PageLoadTest : public UITest { crash_dumps_dir_path_ = base::FilePath::FromUTF8Unsafe( alternate_minidump_location); } else { - PathService::Get(breakpad::DIR_CRASH_DUMPS, &crash_dumps_dir_path_); + PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dumps_dir_path_); } base::FileEnumerator enumerator(crash_dumps_dir_path_, @@ -661,7 +660,7 @@ class PageLoadTest : public UITest { if (!log_path.empty()) { base::FilePath saved_log_file_path = ConstructSavedDebugLogPath(log_path, index); - if (file_util::Move(log_path, saved_log_file_path)) { + if (base::Move(log_path, saved_log_file_path)) { log_file << " " << log_id << "=" << saved_log_file_path.value(); } } diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index b723883b62..8154581f4b 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -31,7 +31,7 @@ #include "base/test/test_file_util.h" #include "base/test/test_timeouts.h" #include "base/threading/platform_thread.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/profiles/profile_impl.h" @@ -51,7 +51,6 @@ #include "chrome/test/base/test_launcher_utils.h" #include "chrome/test/base/test_switches.h" #include "chrome/test/base/testing_profile.h" -#include "components/breakpad/common/breakpad_paths.h" #include "googleurl/src/gurl.h" #include "net/base/net_util.h" #include "ui/gl/gl_implementation.h" @@ -425,7 +424,7 @@ bool UITestBase::CloseBrowser(BrowserProxy* browser, int UITestBase::GetCrashCount() const { base::FilePath crash_dump_path; - PathService::Get(breakpad::DIR_CRASH_DUMPS, &crash_dump_path); + PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); int files_found = 0; base::FileEnumerator en(crash_dump_path, false, base::FileEnumerator::FILES); diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h index 99b360352d..c6cc7ed428 100644 --- a/chrome/test/ui/ui_test.h +++ b/chrome/test/ui/ui_test.h @@ -23,7 +23,7 @@ #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" #include "base/process.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/test/automation/proxy_launcher.h" #include "googleurl/src/gurl.h" #include "testing/platform_test.h" diff --git a/chrome/test/webdriver/keycode_text_conversion_mac.mm b/chrome/test/webdriver/keycode_text_conversion_mac.mm index 7db3366b76..aa2e424824 100644 --- a/chrome/test/webdriver/keycode_text_conversion_mac.mm +++ b/chrome/test/webdriver/keycode_text_conversion_mac.mm @@ -41,7 +41,7 @@ std::string ConvertKeyCodeToText(ui::KeyboardCode key_code, int modifiers) { // on UCKeyTranslate for more info. UInt32 modifier_key_state = (mac_modifiers >> 8) & 0xFF; - base::mac::ScopedCFTypeRef<TISInputSourceRef> input_source_copy( + base::ScopedCFTypeRef<TISInputSourceRef> input_source_copy( TISCopyCurrentKeyboardLayoutInputSource()); CFDataRef layout_data = static_cast<CFDataRef>(TISGetInputSourceProperty( input_source_copy, kTISPropertyUnicodeKeyLayoutData)); diff --git a/chrome/test/webdriver/webdriver_automation.cc b/chrome/test/webdriver/webdriver_automation.cc index 2c2f13d0ea..418e0b2ac7 100644 --- a/chrome/test/webdriver/webdriver_automation.cc +++ b/chrome/test/webdriver/webdriver_automation.cc @@ -440,7 +440,7 @@ void Automation::Init( #elif defined(OS_POSIX) base::FilePath temp_file; if (!file_util::CreateTemporaryFile(&temp_file) || - !file_util::Delete(temp_file, false /* recursive */)) { + !base::Delete(temp_file, false /* recursive */)) { *error = new Error(kUnknownError, "Could not create temporary filename"); return; } diff --git a/chrome/test/webdriver/webdriver_logging.cc b/chrome/test/webdriver/webdriver_logging.cc index 7a56f06484..8698ef4bf3 100644 --- a/chrome/test/webdriver/webdriver_logging.cc +++ b/chrome/test/webdriver/webdriver_logging.cc @@ -12,7 +12,7 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" -#include "base/time.h" +#include "base/time/time.h" #include "build/build_config.h" using base::DictionaryValue; @@ -228,12 +228,9 @@ bool InitWebDriverLogging(const base::FilePath& log_path, LogLevel min_log_level) { start_time = base::Time::Now().ToDoubleT(); // Turn off base/logging. - bool success = InitLogging( - NULL, - logging::LOG_NONE, - logging::DONT_LOCK_LOG_FILE, - logging::DELETE_OLD_LOG_FILE, - logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); + logging::LoggingSettings settings; + settings.logging_dest = logging::LOG_NONE; + bool success = logging::InitLogging(settings); if (!success) { PLOG(ERROR) << "Unable to initialize logging"; } diff --git a/chrome/test/webdriver/webdriver_server.cc b/chrome/test/webdriver/webdriver_server.cc index 1b47258c46..0785fafddf 100644 --- a/chrome/test/webdriver/webdriver_server.cc +++ b/chrome/test/webdriver/webdriver_server.cc @@ -26,7 +26,7 @@ #include "base/synchronization/waitable_event.h" #include "base/test/test_timeouts.h" #include "base/threading/platform_thread.h" -#include "base/time.h" +#include "base/time/time.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" diff --git a/chrome/test/webdriver/webdriver_session.cc b/chrome/test/webdriver/webdriver_session.cc index da8c68bd8c..61ddee870c 100644 --- a/chrome/test/webdriver/webdriver_session.cc +++ b/chrome/test/webdriver/webdriver_session.cc @@ -26,7 +26,7 @@ #include "base/synchronization/waitable_event.h" #include "base/test/test_timeouts.h" #include "base/threading/platform_thread.h" -#include "base/time.h" +#include "base/time/time.h" #include "base/values.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/common/chrome_constants.h" diff --git a/chrome/test/webdriver/webdriver_test_util.cc b/chrome/test/webdriver/webdriver_test_util.cc index 98c8827e4e..0700adcdad 100644 --- a/chrome/test/webdriver/webdriver_test_util.cc +++ b/chrome/test/webdriver/webdriver_test_util.cc @@ -41,15 +41,15 @@ bool SwitchKeyboardLayout(const std::string& input_locale_identifier) { #if defined(OS_MACOSX) bool SwitchKeyboardLayout(const std::string& input_source_id) { - base::mac::ScopedCFTypeRef<CFMutableDictionaryRef> filter_dict( + base::ScopedCFTypeRef<CFMutableDictionaryRef> filter_dict( CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); - base::mac::ScopedCFTypeRef<CFStringRef> id_ref(CFStringCreateWithCString( + base::ScopedCFTypeRef<CFStringRef> id_ref(CFStringCreateWithCString( kCFAllocatorDefault, input_source_id.c_str(), kCFStringEncodingUTF8)); CFDictionaryAddValue(filter_dict, kTISPropertyInputSourceID, id_ref); - base::mac::ScopedCFTypeRef<CFArrayRef> sources( + base::ScopedCFTypeRef<CFArrayRef> sources( TISCreateInputSourceList(filter_dict, true)); if (CFArrayGetCount(sources) != 1) return false; diff --git a/chrome/test/webdriver/webdriver_test_util.h b/chrome/test/webdriver/webdriver_test_util.h index 526ea142e7..0531c589f2 100644 --- a/chrome/test/webdriver/webdriver_test_util.h +++ b/chrome/test/webdriver/webdriver_test_util.h @@ -29,7 +29,7 @@ class RestoreKeyboardLayoutOnDestruct { #if defined(OS_WIN) HKL layout_; #elif defined(OS_MACOSX) - base::mac::ScopedCFTypeRef<TISInputSourceRef> layout_; + base::ScopedCFTypeRef<TISInputSourceRef> layout_; #endif DISALLOW_COPY_AND_ASSIGN(RestoreKeyboardLayoutOnDestruct); |