diff options
author | amit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-24 15:24:05 +0000 |
---|---|---|
committer | amit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-24 15:24:05 +0000 |
commit | 5b811ad2f12a21e218e92d1498f972a4c95ce68d (patch) | |
tree | 2d4ff0078076fd5a566d7543b4d6285fc2a5825e /chrome_frame | |
parent | a973a7147660bff86c36c43a30969bb179492f47 (diff) | |
download | chromium_src-5b811ad2f12a21e218e92d1498f972a4c95ce68d.zip chromium_src-5b811ad2f12a21e218e92d1498f972a4c95ce68d.tar.gz chromium_src-5b811ad2f12a21e218e92d1498f972a4c95ce68d.tar.bz2 |
Test Selenium core on chrome frame
First cut of Selenium core support on Chrome Frame. 2 tests fail.
Selenium tests are now served by mock http server. When the test
is finished it posts a message with number of tests ran and failures.
Also fixed 'attach external tab' mechanism to include the same URL origin
including the port.
BUG=50372
TEST=FullTabSeleniumTest.Core
Review URL: http://codereview.chromium.org/5371001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67264 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/chrome_frame_activex_base.h | 17 | ||||
-rw-r--r-- | chrome_frame/test/chrome_frame_test_utils.cc | 8 | ||||
-rw-r--r-- | chrome_frame/test/chrome_frame_test_utils.h | 3 | ||||
-rw-r--r-- | chrome_frame/test/mock_ie_event_sink_test.cc | 7 | ||||
-rw-r--r-- | chrome_frame/test/mock_ie_event_sink_test.h | 2 | ||||
-rw-r--r-- | chrome_frame/test/navigation_test.cc | 64 | ||||
-rw-r--r-- | chrome_frame/test/test_with_web_server.cc | 3 |
7 files changed, 95 insertions, 9 deletions
diff --git a/chrome_frame/chrome_frame_activex_base.h b/chrome_frame/chrome_frame_activex_base.h index 9389d79..c3bdfeb 100644 --- a/chrome_frame/chrome_frame_activex_base.h +++ b/chrome_frame/chrome_frame_activex_base.h @@ -490,9 +490,6 @@ END_MSG_MAP() std::wstring wide_url = url_; GURL parsed_url(WideToUTF8(wide_url)); - std::string scheme(parsed_url.scheme()); - std::string host(parsed_url.host()); - // If Chrome-Frame is presently navigated to an extension page, navigating // the host to a url with scheme chrome-extension will fail, so we // point the host at http:local_host. Note that this is NOT the URL @@ -501,14 +498,18 @@ END_MSG_MAP() // be constructed in the new IE tab. if (parsed_url.SchemeIs("chrome-extension") && is_privileged_) { - scheme = "http"; - host = "local_host"; + const char kScheme[] = "http"; + const char kHost[] = "local_host"; + + GURL::Replacements r; + r.SetScheme(kScheme, url_parse::Component(0, sizeof(kScheme) -1)); + r.SetHost(kHost, url_parse::Component(0, sizeof(kHost) - 1)); + parsed_url = parsed_url.ReplaceComponents(r); } std::string url = base::StringPrintf( - "%hs://%hs?attach_external_tab&%I64u&%d&%d&%d&%d&%d&%hs", - scheme.c_str(), - host.c_str(), + "%hs?attach_external_tab&%I64u&%d&%d&%d&%d&%d&%hs", + parsed_url.GetOrigin().spec().c_str(), params.cookie, params.disposition, params.dimensions.x(), diff --git a/chrome_frame/test/chrome_frame_test_utils.cc b/chrome_frame/test/chrome_frame_test_utils.cc index 7d6a28b..5917022 100644 --- a/chrome_frame/test/chrome_frame_test_utils.cc +++ b/chrome_frame/test/chrome_frame_test_utils.cc @@ -454,6 +454,14 @@ FilePath GetTestDataFolder() { return test_dir; } +FilePath GetSeleniumTestFolder() { + FilePath test_dir; + PathService::Get(base::DIR_SOURCE_ROOT, &test_dir); + test_dir = test_dir.Append(FILE_PATH_LITERAL("data")) + .Append(FILE_PATH_LITERAL("selenium_core")); + return test_dir; +} + std::wstring GetPathFromUrl(const std::wstring& url) { string16 url16 = WideToUTF16(url); GURL gurl = GURL(url16); diff --git a/chrome_frame/test/chrome_frame_test_utils.h b/chrome_frame/test/chrome_frame_test_utils.h index 6bd787f..daae5bc 100644 --- a/chrome_frame/test/chrome_frame_test_utils.h +++ b/chrome_frame/test/chrome_frame_test_utils.h @@ -139,6 +139,9 @@ IEVersion GetInstalledIEVersion(); // Returns the folder for CF test data. FilePath GetTestDataFolder(); +// Returns the folder for Selenium core. +FilePath GetSeleniumTestFolder(); + // Returns the path portion of the url. std::wstring GetPathFromUrl(const std::wstring& url); diff --git a/chrome_frame/test/mock_ie_event_sink_test.cc b/chrome_frame/test/mock_ie_event_sink_test.cc index 98119ed..c591744 100644 --- a/chrome_frame/test/mock_ie_event_sink_test.cc +++ b/chrome_frame/test/mock_ie_event_sink_test.cc @@ -179,6 +179,13 @@ MockIEEventSinkTest::MockIEEventSinkTest() : server_mock_(1337, L"127.0.0.1", .WillRepeatedly(SendFast("HTTP/1.1 404 Not Found", "")); } +MockIEEventSinkTest::MockIEEventSinkTest(int port, const std::wstring& address, + const FilePath& root_dir) + : server_mock_(port, address, root_dir) { + EXPECT_CALL(server_mock_, Get(_, StrCaseEq(L"/favicon.ico"), _)) + .WillRepeatedly(SendFast("HTTP/1.1 404 Not Found", "")); +} + void MockIEEventSinkTest::LaunchIEAndNavigate(const std::wstring& url) { LaunchIENavigateAndLoop(url, kChromeFrameLongNavigationTimeoutInSeconds); } diff --git a/chrome_frame/test/mock_ie_event_sink_test.h b/chrome_frame/test/mock_ie_event_sink_test.h index 7e48137..87cd2f2 100644 --- a/chrome_frame/test/mock_ie_event_sink_test.h +++ b/chrome_frame/test/mock_ie_event_sink_test.h @@ -275,6 +275,8 @@ class MockAccEventObserver : public AccEventObserver { class MockIEEventSinkTest { public: MockIEEventSinkTest(); + MockIEEventSinkTest(int port, const std::wstring& address, + const FilePath& root_dir); ~MockIEEventSinkTest() { // Detach manually here so that it occurs before |last_resort_close_ie_| diff --git a/chrome_frame/test/navigation_test.cc b/chrome_frame/test/navigation_test.cc index e73ec2c..0ce2a6c 100644 --- a/chrome_frame/test/navigation_test.cc +++ b/chrome_frame/test/navigation_test.cc @@ -955,4 +955,68 @@ TEST_P(FullTabNavigationTest, RefreshContents) { LaunchIEAndNavigate(src_url); } +class FullTabSeleniumTest + : public MockIEEventSinkTest, public testing::TestWithParam<CFInvocation> { + public: + FullTabSeleniumTest() + : MockIEEventSinkTest(1337, L"127.0.0.1", GetSeleniumTestFolder()) {} +}; + +ACTION(VerifySeleniumCoreTestResults) { + int num_tests = 0; + int failed_tests = 0; + + swscanf(arg0, L"%d/%d", &num_tests, &failed_tests); + + // Currently we run total 505 tests and 8 steps fail. + // TODO(amit): send results as JSON, diagnose and eliminate failures. + ASSERT_EQ(num_tests, 505) << "Expected to run: " << 505 << " tests." << + " Actual number of tests run: " << num_tests; + ASSERT_LE(failed_tests, 8) << "Expected failures: " << 8 << + " Actual failures: " << failed_tests; +} + +// Tests refreshing causes a page load. +TEST_F(FullTabSeleniumTest, Core) { + server_mock_.ExpectAndServeAnyRequests(CFInvocation::HttpHeader()); + std::wstring url = GetTestUrl(L"core/TestRunner.html"); + + // Expectations for TestRunner.html + EXPECT_CALL(ie_mock_, OnFileDownload(_, _)).Times(testing::AnyNumber()); + EXPECT_CALL(ie_mock_, OnBeforeNavigate2(_, + testing::Field(&VARIANT::bstrVal, + testing::StartsWith(url)), _, _, _, _, _)) + .Times(testing::AnyNumber()); + EXPECT_CALL(ie_mock_, OnNavigateComplete2(_, + testing::Field(&VARIANT::bstrVal, + testing::StartsWith(url)))) + .Times(testing::AnyNumber()); + EXPECT_CALL(ie_mock_, OnLoad(true, testing::StartsWith(url))) + .Times(testing::AnyNumber()); + + // Expectation for cookie test + EXPECT_CALL(ie_mock_, OnLoadError(testing::StartsWith(url))) + .Times(3); + + // Expectations for popups + std::wstring attach_url_prefix = GetTestUrl(L"?attach_external_tab&"); + EXPECT_CALL(ie_mock_, OnNewWindow3(_, _, _, _, + testing::StartsWith(attach_url_prefix))) + .Times(testing::AnyNumber()); + EXPECT_CALL(ie_mock_, OnNewBrowserWindow(_, + testing::StartsWith(attach_url_prefix))) + .Times(testing::AnyNumber()); + + // At the end the tests will post us a message. See _onTestSuiteComplete in + // ...\src\data\selenium_core\core\scripts\selenium-testrunner.js + EXPECT_CALL(ie_mock_, OnMessage(_, _, _)) + .WillOnce(testing::DoAll(VerifySeleniumCoreTestResults(), + CloseBrowserMock(&ie_mock_))); + + // Selenium tests take longer to finish, lets give it 2 mins. + const int kSeleniumTestTimeout = 120; + LaunchIENavigateAndLoop(url, kSeleniumTestTimeout); +} + + } // namespace chrome_frame_test diff --git a/chrome_frame/test/test_with_web_server.cc b/chrome_frame/test/test_with_web_server.cc index 9c4b761..03dff3f 100644 --- a/chrome_frame/test/test_with_web_server.cc +++ b/chrome_frame/test/test_with_web_server.cc @@ -354,7 +354,8 @@ void MockWebServer::SendResponseHelper( std::string headers, body; std::string content_type; - if (file_util::PathExists(file_path)) { + if (file_util::PathExists(file_path) && + !file_util::DirectoryExists(file_path)) { FilePath mock_http_headers(file_path.value() + L".mock-http-headers"); if (file_util::PathExists(mock_http_headers)) { headers = GetMockHttpHeaders(mock_http_headers); |