summaryrefslogtreecommitdiffstats
path: root/chrome_frame/test
diff options
context:
space:
mode:
Diffstat (limited to 'chrome_frame/test')
-rw-r--r--chrome_frame/test/automation_client_mock.cc33
-rw-r--r--chrome_frame/test/automation_client_mock.h16
-rw-r--r--chrome_frame/test/chrome_frame_automation_mock.h8
-rw-r--r--chrome_frame/test/chrome_frame_test_utils.cc11
-rw-r--r--chrome_frame/test/chrome_frame_test_utils.h6
5 files changed, 51 insertions, 23 deletions
diff --git a/chrome_frame/test/automation_client_mock.cc b/chrome_frame/test/automation_client_mock.cc
index f699635..36edc57 100644
--- a/chrome_frame/test/automation_client_mock.cc
+++ b/chrome_frame/test/automation_client_mock.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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_frame/test/automation_client_mock.h"
@@ -44,7 +44,7 @@ void MockProxyFactory::GetServerImpl(ChromeFrameAutomationProxy* pxy,
void CFACMockTest::SetAutomationServerOk() {
EXPECT_CALL(factory_, GetAutomationServer(testing::NotNull(),
testing::Field(&ChromeFrameLaunchParams::profile_name,
- testing::StrEq(profile_)),
+ testing::StrEq(profile_path_.BaseName().ToWStringHack())),
testing::NotNull()))
.Times(1)
.WillOnce(testing::Invoke(CreateFunctor(&factory_,
@@ -91,7 +91,8 @@ TEST(CFACWithChrome, CreateTooFast) {
MockCFDelegate cfd;
chrome_frame_test::TimedMsgLoop loop;
int timeout = 0; // Chrome cannot send Hello message so fast.
- const std::wstring profile = L"Adam.N.Epilinter";
+ const FilePath profile_path(
+ chrome_frame_test::GetProfilePath(L"Adam.N.Epilinter"));
scoped_refptr<ChromeFrameAutomationClient> client;
client = new ChromeFrameAutomationClient();
@@ -100,7 +101,8 @@ TEST(CFACWithChrome, CreateTooFast) {
.Times(1)
.WillOnce(QUIT_LOOP(loop));
- EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile, L"", false));
+ EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile_path, L"",
+ false));
loop.RunFor(10);
client->Uninitialize();
}
@@ -112,7 +114,8 @@ TEST(CFACWithChrome, CreateTooFast) {
TEST(CFACWithChrome, CreateNotSoFast) {
MockCFDelegate cfd;
chrome_frame_test::TimedMsgLoop loop;
- const std::wstring profile = L"Adam.N.Epilinter";
+ const FilePath profile_path(
+ chrome_frame_test::GetProfilePath(L"Adam.N.Epilinter"));
int timeout = 10000;
scoped_refptr<ChromeFrameAutomationClient> client;
@@ -125,7 +128,8 @@ TEST(CFACWithChrome, CreateNotSoFast) {
EXPECT_CALL(cfd, OnAutomationServerLaunchFailed(_, _))
.Times(0);
- EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile, L"", false));
+ EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile_path, L"",
+ false));
loop.RunFor(11);
client->Uninitialize();
@@ -135,8 +139,9 @@ TEST(CFACWithChrome, CreateNotSoFast) {
TEST(CFACWithChrome, NavigateOk) {
MockCFDelegate cfd;
chrome_frame_test::TimedMsgLoop loop;
- const std::wstring profile = L"Adam.N.Epilinter";
const std::string url = "about:version";
+ const FilePath profile_path(
+ chrome_frame_test::GetProfilePath(L"Adam.N.Epilinter"));
int timeout = 10000;
scoped_refptr<ChromeFrameAutomationClient> client;
@@ -165,7 +170,8 @@ TEST(CFACWithChrome, NavigateOk) {
.WillOnce(QUIT_LOOP(loop));
}
- EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile, L"", false));
+ EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile_path, L"",
+ false));
loop.RunFor(10);
client->Uninitialize();
client = NULL;
@@ -174,7 +180,8 @@ TEST(CFACWithChrome, NavigateOk) {
TEST(CFACWithChrome, NavigateFailed) {
MockCFDelegate cfd;
chrome_frame_test::TimedMsgLoop loop;
- const std::wstring profile = L"Adam.N.Epilinter";
+ const FilePath profile_path(
+ chrome_frame_test::GetProfilePath(L"Adam.N.Epilinter"));
const std::string url = "http://127.0.0.3:65412/";
const URLRequestStatus connection_failed(URLRequestStatus::FAILED,
net::ERR_INVALID_URL);
@@ -204,7 +211,8 @@ TEST(CFACWithChrome, NavigateFailed) {
.Times(1)
.WillOnce(QUIT_LOOP_SOON(loop, 2));
- EXPECT_TRUE(client->Initialize(&cfd, 10000, false, profile, L"", false));
+ EXPECT_TRUE(client->Initialize(&cfd, 10000, false, profile_path, L"",
+ false));
loop.RunFor(10);
client->Uninitialize();
@@ -237,7 +245,8 @@ TEST_F(CFACMockTest, MockedCreateTabOk) {
EXPECT_CALL(proxy_, CancelAsync(_)).Times(testing::AnyNumber());
// Here we go!
- EXPECT_TRUE(client_->Initialize(&cfd_, timeout, false, profile_, L"", false));
+ EXPECT_TRUE(client_->Initialize(&cfd_, timeout, false, profile_path_, L"",
+ false));
loop_.RunFor(10);
client_->Uninitialize();
}
@@ -262,7 +271,7 @@ TEST_F(CFACMockTest, MockedCreateTabFailed) {
Set_CFD_LaunchFailed(AUTOMATION_CREATE_TAB_FAILED);
// Here we go!
- EXPECT_TRUE(client_->Initialize(&cfd_, timeout_, false, profile_, L"",
+ EXPECT_TRUE(client_->Initialize(&cfd_, timeout_, false, profile_path_, L"",
false));
loop_.RunFor(4);
client_->Uninitialize();
diff --git a/chrome_frame/test/automation_client_mock.h b/chrome_frame/test/automation_client_mock.h
index b81a582..4f65bbb 100644
--- a/chrome_frame/test/automation_client_mock.h
+++ b/chrome_frame/test/automation_client_mock.h
@@ -1,8 +1,8 @@
-// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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_FRAME_AUTOMATION_CLIENT_MOCK_H_
-#define CHROME_FRAME_AUTOMATION_CLIENT_MOCK_H_
+#ifndef CHROME_FRAME_TEST_AUTOMATION_CLIENT_MOCK_H_
+#define CHROME_FRAME_TEST_AUTOMATION_CLIENT_MOCK_H_
#include <windows.h>
#include <string>
@@ -137,7 +137,7 @@ class CFACMockTest : public testing::Test {
// the victim of all tests
scoped_refptr<ChromeFrameAutomationClient> client_;
- std::wstring profile_;
+ FilePath profile_path_;
int timeout_;
void* id_; // Automation server id we are going to return
int tab_handle_; // Tab handle. Any non-zero value is Ok.
@@ -156,8 +156,10 @@ class CFACMockTest : public testing::Test {
void Set_CFD_LaunchFailed(AutomationLaunchResult result);
protected:
- CFACMockTest() : tracker_(NULL), timeout_(500),
- profile_(L"Adam.N.Epilinter") {
+ CFACMockTest()
+ : tracker_(NULL), timeout_(500),
+ profile_path_(
+ chrome_frame_test::GetProfilePath(L"Adam.N.Epilinter")) {
id_ = reinterpret_cast<void*>(5);
tab_handle_ = 3;
}
@@ -172,5 +174,5 @@ class CFACMockTest : public testing::Test {
};
-#endif // CHROME_FRAME_AUTOMATION_CLIENT_MOCK_H_
+#endif // CHROME_FRAME_TEST_AUTOMATION_CLIENT_MOCK_H_
diff --git a/chrome_frame/test/chrome_frame_automation_mock.h b/chrome_frame/test/chrome_frame_automation_mock.h
index 6fea200..11d186f 100644
--- a/chrome_frame/test/chrome_frame_automation_mock.h
+++ b/chrome_frame/test/chrome_frame_automation_mock.h
@@ -11,6 +11,8 @@
#include "chrome_frame/chrome_frame_automation.h"
#include "chrome_frame/chrome_frame_plugin.h"
#include "chrome_frame/test/http_server.h"
+#include "chrome_frame/test/chrome_frame_test_utils.h"
+#include "chrome_frame/utils.h"
template <typename T>
class AutomationMockDelegate
@@ -24,9 +26,13 @@ class AutomationMockDelegate
: caller_message_loop_(caller_message_loop), is_connected_(false),
navigation_result_(false) {
test_server_.SetUp();
+
+ FilePath profile_path(
+ chrome_frame_test::GetProfilePath(profile_name));
+
automation_client_ = new ChromeFrameAutomationClient;
automation_client_->Initialize(this, launch_timeout, perform_version_check,
- profile_name, extra_chrome_arguments, incognito);
+ profile_path, extra_chrome_arguments, incognito);
}
~AutomationMockDelegate() {
if (automation_client_.get()) {
diff --git a/chrome_frame/test/chrome_frame_test_utils.cc b/chrome_frame/test/chrome_frame_test_utils.cc
index c2f0abb..9c82b20 100644
--- a/chrome_frame/test/chrome_frame_test_utils.cc
+++ b/chrome_frame/test/chrome_frame_test_utils.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -18,7 +18,10 @@
#include "base/utf_string_conversions.h"
#include "base/win_util.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_paths_internal.h"
#include "chrome_frame/utils.h"
+
#include "testing/gtest/include/gtest/gtest.h"
namespace chrome_frame_test {
@@ -361,6 +364,12 @@ HRESULT LaunchIEAsComServer(IWebBrowser2** web_browser) {
return hr;
}
+FilePath GetProfilePath(const std::wstring& profile_name) {
+ FilePath profile_path;
+ chrome::GetChromeFrameUserDataDirectory(&profile_path);
+ return profile_path.Append(profile_name);
+}
+
_ATL_FUNC_INFO WebBrowserEventSink::kNavigateErrorInfo = {
CC_STDCALL, VT_EMPTY, 5, {
VT_DISPATCH,
diff --git a/chrome_frame/test/chrome_frame_test_utils.h b/chrome_frame/test/chrome_frame_test_utils.h
index c766861..9040d9a 100644
--- a/chrome_frame/test/chrome_frame_test_utils.h
+++ b/chrome_frame/test/chrome_frame_test_utils.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -115,6 +115,8 @@ class TimedMsgLoop {
// Returns S_OK on success.
HRESULT LaunchIEAsComServer(IWebBrowser2** web_browser);
+FilePath GetProfilePath(const std::wstring& suffix);
+
#ifndef DISPID_NEWPROCESS
#define DISPID_NEWPROCESS 284
#endif // DISPID_NEWPROCESS
@@ -255,7 +257,7 @@ END_SINK_MAP()
virtual void OnNewBrowserWindow(IDispatch* new_window, const wchar_t* url) {}
// Window watchdog override
- virtual void OnWindowDetected(HWND hwnd, const std::string& caption) {};
+ virtual void OnWindowDetected(HWND hwnd, const std::string& caption) {}
IWebBrowser2* web_browser2() {
return web_browser2_.get();