summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-11 00:05:16 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-11 00:05:16 +0000
commit068970d4e8a15c8915c3e3b1df16c71428a20ba5 (patch)
treecdc5e6313d188f3044a603ffc826c0b81da7e1bd
parent771c173105e8f68812fb386e278773adee6319ce (diff)
downloadchromium_src-068970d4e8a15c8915c3e3b1df16c71428a20ba5.zip
chromium_src-068970d4e8a15c8915c3e3b1df16c71428a20ba5.tar.gz
chromium_src-068970d4e8a15c8915c3e3b1df16c71428a20ba5.tar.bz2
Don't expose RenderViewImpl to tests which use RenderViewTest through its header. Instead add a few methods to RenderViewTest that Chrome tests need.
BUG=98716 Review URL: http://codereview.chromium.org/8222014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104826 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/renderer/autofill/autofill_browsertest.cc4
-rw-r--r--chrome/renderer/content_settings_observer_browsertest.cc11
-rw-r--r--chrome/renderer/page_click_tracker_browsertest.cc8
-rw-r--r--chrome/renderer/print_web_view_helper_browsertest.cc9
-rw-r--r--chrome/renderer/safe_browsing/phishing_thumbnailer_browsertest.cc2
-rw-r--r--chrome/renderer/translate_helper_browsertest.cc5
-rw-r--r--chrome/test/base/render_view_test.cc67
-rw-r--r--chrome/test/base/render_view_test.h32
-rw-r--r--content/renderer/external_popup_menu_unittest.cc17
-rw-r--r--content/renderer/render_view_browsertest.cc353
-rw-r--r--content/renderer/render_view_browsertest_mac.mm17
-rw-r--r--content/renderer/render_view_impl.h27
-rw-r--r--content/test/render_widget_browsertest.cc14
13 files changed, 322 insertions, 244 deletions
diff --git a/chrome/renderer/autofill/autofill_browsertest.cc b/chrome/renderer/autofill/autofill_browsertest.cc
index ef1fe87..9648532 100644
--- a/chrome/renderer/autofill/autofill_browsertest.cc
+++ b/chrome/renderer/autofill/autofill_browsertest.cc
@@ -25,7 +25,7 @@ TEST_F(RenderViewTest, SendForms) {
// Don't want any delay for form state sync changes. This will still post a
// message so updates will get coalesced, but as soon as we spin the message
// loop, it will generate an update.
- view_->set_send_content_state_immediately(true);
+ SendContentStateImmediately();
LoadHTML("<form method=\"POST\">"
" <input type=\"text\" id=\"firstname\"/>"
@@ -125,7 +125,7 @@ TEST_F(RenderViewTest, FillFormElement) {
// Don't want any delay for form state sync changes. This will still post a
// message so updates will get coalesced, but as soon as we spin the message
// loop, it will generate an update.
- view_->set_send_content_state_immediately(true);
+ SendContentStateImmediately();
LoadHTML("<form method=\"POST\">"
" <input type=\"text\" id=\"firstname\"/>"
diff --git a/chrome/renderer/content_settings_observer_browsertest.cc b/chrome/renderer/content_settings_observer_browsertest.cc
index 0dd54b4..206fd6f 100644
--- a/chrome/renderer/content_settings_observer_browsertest.cc
+++ b/chrome/renderer/content_settings_observer_browsertest.cc
@@ -7,6 +7,7 @@
#include "chrome/renderer/content_settings_observer.h"
#include "chrome/test/base/render_view_test.h"
#include "content/common/view_messages.h"
+#include "content/public/renderer/render_view.h"
#include "ipc/ipc_message_macros.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -79,11 +80,11 @@ TEST_F(RenderViewTest, AllowDOMStorage) {
OnAllowDOMStorage(_, _, _, _, _)).WillByDefault(DeleteArg<4>());
EXPECT_CALL(observer,
OnAllowDOMStorage(_, _, _, _, _));
- observer.AllowStorage(view_->webview()->focusedFrame(), true);
+ observer.AllowStorage(view_->GetWebView()->focusedFrame(), true);
// Accessing localStorage from the same origin again shouldn't result in a
// new IPC.
- observer.AllowStorage(view_->webview()->focusedFrame(), true);
+ observer.AllowStorage(view_->GetWebView()->focusedFrame(), true);
::testing::Mock::VerifyAndClearExpectations(&observer);
}
@@ -120,7 +121,7 @@ TEST_F(RenderViewTest, JSBlockSentAfterPageLoad) {
GURL url(url_str);
params.url = url;
params.navigation_type = ViewMsg_Navigate_Type::RELOAD;
- view_->OnNavigate(params);
+ OnNavigate(params);
ProcessPendingMessages();
// 4. Verify that the notification that javascript was blocked is sent after
@@ -155,12 +156,12 @@ TEST_F(RenderViewTest, PluginsTemporarilyAllowed) {
observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS));
// Temporarily allow plugins.
- view_->OnMessageReceived(ChromeViewMsg_LoadBlockedPlugins(MSG_ROUTING_NONE));
+ OnMessageReceived(ChromeViewMsg_LoadBlockedPlugins(MSG_ROUTING_NONE));
EXPECT_EQ(CONTENT_SETTING_ALLOW,
observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS));
// Simulate a navigation within the page.
- view_->didNavigateWithinPage(GetMainFrame(), true);
+ DidNavigateWithinPage(GetMainFrame(), true);
EXPECT_EQ(CONTENT_SETTING_ALLOW,
observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS));
diff --git a/chrome/renderer/page_click_tracker_browsertest.cc b/chrome/renderer/page_click_tracker_browsertest.cc
index 39d9122..f960553 100644
--- a/chrome/renderer/page_click_tracker_browsertest.cc
+++ b/chrome/renderer/page_click_tracker_browsertest.cc
@@ -3,11 +3,11 @@
// found in the LICENSE file.
#include "base/basictypes.h"
-
#include "chrome/common/render_messages.h"
#include "chrome/renderer/page_click_listener.h"
#include "chrome/renderer/page_click_tracker.h"
#include "chrome/test/base/render_view_test.h"
+#include "content/public/renderer/render_view.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h"
@@ -62,9 +62,9 @@ TEST_F(RenderViewTest, PageClickTracker) {
" <input type='text' id='text'></input><br>"
" <input type='button' id='button'></input><br>"
"</form>");
- view_->webwidget()->resize(WebKit::WebSize(500, 500));
- view_->webwidget()->setFocus(true);
- WebKit::WebDocument document = view_->webview()->mainFrame()->document();
+ GetWebWidget()->resize(WebKit::WebSize(500, 500));
+ GetWebWidget()->setFocus(true);
+ WebKit::WebDocument document = view_->GetWebView()->mainFrame()->document();
WebKit::WebElement text = document.getElementById("text");
ASSERT_FALSE(text.isNull());
WebKit::WebElement button = document.getElementById("button");
diff --git a/chrome/renderer/print_web_view_helper_browsertest.cc b/chrome/renderer/print_web_view_helper_browsertest.cc
index 756f944..d784e80 100644
--- a/chrome/renderer/print_web_view_helper_browsertest.cc
+++ b/chrome/renderer/print_web_view_helper_browsertest.cc
@@ -6,6 +6,7 @@
#include "chrome/common/print_messages.h"
#include "chrome/renderer/print_web_view_helper.h"
#include "chrome/test/base/render_view_test.h"
+#include "content/public/renderer/render_view.h"
#include "printing/print_job_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
@@ -190,11 +191,11 @@ TEST_F(PrintWebViewHelperTest, PrintWithIframe) {
// Find the frame and set it as the focused one. This should mean that that
// the printout should only contain the contents of that frame.
WebFrame* sub1_frame =
- view_->webview()->findFrameByName(WebString::fromUTF8("sub1"));
+ view_->GetWebView()->findFrameByName(WebString::fromUTF8("sub1"));
ASSERT_TRUE(sub1_frame);
- view_->webview()->setFocusedFrame(sub1_frame);
- ASSERT_NE(view_->webview()->focusedFrame(),
- view_->webview()->mainFrame());
+ view_->GetWebView()->setFocusedFrame(sub1_frame);
+ ASSERT_NE(view_->GetWebView()->focusedFrame(),
+ view_->GetWebView()->mainFrame());
// Initiate printing.
PrintWebViewHelper::Get(view_)->OnPrintPages();
diff --git a/chrome/renderer/safe_browsing/phishing_thumbnailer_browsertest.cc b/chrome/renderer/safe_browsing/phishing_thumbnailer_browsertest.cc
index 3e4275a..4918137 100644
--- a/chrome/renderer/safe_browsing/phishing_thumbnailer_browsertest.cc
+++ b/chrome/renderer/safe_browsing/phishing_thumbnailer_browsertest.cc
@@ -21,7 +21,7 @@ class ThumbnailerTest : public RenderWidgetTest {
const gfx::Size& desired_size,
SkBitmap* snapshot) {
ASSERT_TRUE(snapshot);
- *snapshot = GrabPhishingThumbnail(view_.get(), page_size, desired_size);
+ *snapshot = GrabPhishingThumbnail(view_, page_size, desired_size);
EXPECT_FALSE(snapshot->isNull());
}
};
diff --git a/chrome/renderer/translate_helper_browsertest.cc b/chrome/renderer/translate_helper_browsertest.cc
index 20434a9..56ead08 100644
--- a/chrome/renderer/translate_helper_browsertest.cc
+++ b/chrome/renderer/translate_helper_browsertest.cc
@@ -6,6 +6,7 @@
#include "chrome/common/render_messages.h"
#include "chrome/renderer/translate_helper.h"
#include "chrome/test/base/render_view_test.h"
+#include "content/public/renderer/render_view.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -301,7 +302,7 @@ TEST_F(TranslateHelperTest, MultipleDifferentTranslations) {
TEST_F(RenderViewTest, TranslatablePage) {
// Suppress the normal delay that occurs when the page is loaded before which
// the renderer sends the page contents to the browser.
- view_->set_send_content_state_immediately(true);
+ SendContentStateImmediately();
LoadHTML("<html><body>A random page with random content.</body></html>");
ProcessPendingMessages();
@@ -340,7 +341,7 @@ TEST_F(RenderViewTest, TranslatablePage) {
TEST_F(RenderViewTest, LanguageMetaTag) {
// Suppress the normal delay that occurs when the page is loaded before which
// the renderer sends the page contents to the browser.
- view_->set_send_content_state_immediately(true);
+ SendContentStateImmediately();
LoadHTML("<html><head><meta http-equiv=\"content-language\" content=\"es\">"
"</head><body>A random page with random content.</body></html>");
diff --git a/chrome/test/base/render_view_test.cc b/chrome/test/base/render_view_test.cc
index 60f1507..0734dc0 100644
--- a/chrome/test/base/render_view_test.cc
+++ b/chrome/test/base/render_view_test.cc
@@ -19,6 +19,7 @@
#include "content/common/native_web_keyboard_event.h"
#include "content/common/renderer_preferences.h"
#include "content/common/view_messages.h"
+#include "content/renderer/render_view_impl.h"
#include "content/renderer/renderer_main_platform_delegate.h"
#include "content/test/mock_render_process.h"
#include "grit/renderer_resources.h"
@@ -50,7 +51,7 @@ const int32 kRouteId = 5;
const int32 kOpenerId = 7;
} // namespace
-RenderViewTest::RenderViewTest() : extension_dispatcher_(NULL) {
+RenderViewTest::RenderViewTest() : extension_dispatcher_(NULL), view_(NULL) {
}
RenderViewTest::~RenderViewTest() {
@@ -62,7 +63,7 @@ void RenderViewTest::ProcessPendingMessages() {
}
WebFrame* RenderViewTest::GetMainFrame() {
- return view_->webview()->mainFrame();
+ return view_->GetWebView()->mainFrame();
}
void RenderViewTest::ExecuteJavaScript(const char* js) {
@@ -127,14 +128,17 @@ void RenderViewTest::SetUp() {
render_thread_.set_routing_id(kRouteId);
// This needs to pass the mock render thread to the view.
- view_ = RenderViewImpl::Create(0,
- kOpenerId,
- RendererPreferences(),
- WebPreferences(),
- new SharedRenderViewCounter(0),
- kRouteId,
- kInvalidSessionStorageNamespaceId,
- string16());
+ RenderViewImpl* view = RenderViewImpl::Create(
+ 0,
+ kOpenerId,
+ RendererPreferences(),
+ WebPreferences(),
+ new SharedRenderViewCounter(0),
+ kRouteId,
+ kInvalidSessionStorageNamespaceId,
+ string16());
+ view->AddRef();
+ view_ = view;
// Attach a pseudo keyboard device to this object.
mock_keyboard_.reset(new MockKeyboard());
@@ -156,6 +160,8 @@ void RenderViewTest::TearDown() {
// Run the loop so the release task from the renderwidget executes.
ProcessPendingMessages();
+ RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
+ impl->Release();
view_ = NULL;
mock_process_.reset();
@@ -255,7 +261,8 @@ void RenderViewTest::SendNativeKeyEvent(
scoped_ptr<IPC::Message> input_message(new ViewMsg_HandleInputEvent(0));
input_message->WriteData(reinterpret_cast<const char*>(&key_event),
sizeof(WebKit::WebKeyboardEvent));
- view_->OnMessageReceived(*input_message);
+ RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
+ impl->OnMessageReceived(*input_message);
}
const char* const kGetCoordinatesScript =
@@ -317,13 +324,41 @@ bool RenderViewTest::SimulateElementClick(const std::string& element_id) {
scoped_ptr<IPC::Message> input_message(new ViewMsg_HandleInputEvent(0));
input_message->WriteData(reinterpret_cast<const char*>(&mouse_event),
sizeof(WebMouseEvent));
- view_->OnMessageReceived(*input_message);
+ RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
+ impl->OnMessageReceived(*input_message);
return true;
}
void RenderViewTest::ClearHistory() {
- view_->page_id_ = -1;
- view_->history_list_offset_ = -1;
- view_->history_list_length_ = 0;
- view_->history_page_ids_.clear();
+ RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
+ impl->page_id_ = -1;
+ impl->history_list_offset_ = -1;
+ impl->history_list_length_ = 0;
+ impl->history_page_ids_.clear();
+}
+
+bool RenderViewTest::OnMessageReceived(const IPC::Message& msg) {
+ RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
+ return impl->OnMessageReceived(msg);
+}
+
+void RenderViewTest::OnNavigate(const ViewMsg_Navigate_Params& params) {
+ RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
+ impl->OnNavigate(params);
+}
+
+void RenderViewTest::DidNavigateWithinPage(WebKit::WebFrame* frame,
+ bool is_new_navigation) {
+ RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
+ impl->didNavigateWithinPage(frame, is_new_navigation);
+}
+
+void RenderViewTest::SendContentStateImmediately() {
+ RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
+ impl->set_send_content_state_immediately(true);
+}
+
+WebKit::WebWidget* RenderViewTest::GetWebWidget() {
+ RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
+ return impl->webwidget();
}
diff --git a/chrome/test/base/render_view_test.h b/chrome/test/base/render_view_test.h
index 96081c4..c757280 100644
--- a/chrome/test/base/render_view_test.h
+++ b/chrome/test/base/render_view_test.h
@@ -17,21 +17,32 @@
#include "content/common/main_function_params.h"
#include "content/common/native_web_keyboard_event.h"
#include "content/common/sandbox_init_wrapper.h"
-#include "content/renderer/render_view_impl.h"
#include "content/renderer/renderer_webkitplatformsupport_impl.h"
#include "chrome/renderer/chrome_content_renderer_client.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
+class ExtensionDispatcher;
+class MockRenderProcess;
+class RendererMainPlatformDelegate;
+struct ViewMsg_Navigate_Params;
+
+namespace WebKit {
+class WebWidget;
+}
+
namespace autofill {
class AutofillAgent;
class PasswordAutofillManager;
}
-class ExtensionDispatcher;
-class MockRenderProcess;
-class RendererMainPlatformDelegate;
-class RenderViewImpl;
+namespace content {
+class RenderView;
+}
+
+namespace gfx {
+class Rect;
+}
class RenderViewTest : public testing::Test {
public:
@@ -89,6 +100,13 @@ class RenderViewTest : public testing::Test {
// Clears anything associated with the browsing history.
void ClearHistory();
+ // These are all methods from RenderViewImpl that we expose to testing code.
+ bool OnMessageReceived(const IPC::Message& msg);
+ void OnNavigate(const ViewMsg_Navigate_Params& params);
+ void DidNavigateWithinPage(WebKit::WebFrame* frame, bool is_new_navigation);
+ void SendContentStateImmediately();
+ WebKit::WebWidget* GetWebWidget();
+
// testing::Test
virtual void SetUp();
@@ -99,7 +117,9 @@ class RenderViewTest : public testing::Test {
ExtensionDispatcher* extension_dispatcher_;
MockRenderThread render_thread_;
scoped_ptr<MockRenderProcess> mock_process_;
- scoped_refptr<RenderViewImpl> view_;
+ // We use a naked pointer because we don't want to expose RenderViewImpl in
+ // the embedder's namespace.
+ content::RenderView* view_;
RendererWebKitPlatformSupportImplNoSandbox webkit_platform_support_;
scoped_ptr<MockKeyboard> mock_keyboard_;
diff --git a/content/renderer/external_popup_menu_unittest.cc b/content/renderer/external_popup_menu_unittest.cc
index 13a295b..e6578e7 100644
--- a/content/renderer/external_popup_menu_unittest.cc
+++ b/content/renderer/external_popup_menu_unittest.cc
@@ -5,6 +5,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/test/base/render_view_test.h"
#include "content/common/view_messages.h"
+#include "content/renderer/render_view_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
@@ -22,6 +23,10 @@ class ExternalPopupMenuTest : public RenderViewTest {
public:
ExternalPopupMenuTest() {}
+ RenderViewImpl* view() {
+ return static_cast<RenderViewImpl*>(view_);
+ }
+
virtual void SetUp() {
RenderViewTest::SetUp();
// We need to set this explictly as RenderMain is not run.
@@ -46,8 +51,8 @@ class ExternalPopupMenuTest : public RenderViewTest {
LoadHTML(html.c_str());
// Set a minimum size and give focus so simulated events work.
- view_->webwidget()->resize(WebKit::WebSize(500, 500));
- view_->webwidget()->setFocus(true);
+ view()->webwidget()->resize(WebKit::WebSize(500, 500));
+ view()->webwidget()->setFocus(true);
}
int GetSelectedIndex() {
@@ -81,12 +86,12 @@ TEST_F(ExternalPopupMenuTest, NormalCase) {
EXPECT_EQ(1, param.a.selected_item);
// Simulate the user canceling the popup, the index should not have changed.
- view_->OnSelectPopupMenuItem(-1);
+ view()->OnSelectPopupMenuItem(-1);
EXPECT_EQ(1, GetSelectedIndex());
// Show the pop-up again and this time make a selection.
EXPECT_TRUE(SimulateElementClick(kSelectID));
- view_->OnSelectPopupMenuItem(0);
+ view()->OnSelectPopupMenuItem(0);
EXPECT_EQ(0, GetSelectedIndex());
// Show the pop-up again and make another selection.
@@ -108,7 +113,7 @@ TEST_F(ExternalPopupMenuTest, ShowPopupThenNavigate) {
LoadHTML("<blink>Awesome page!</blink>");
// Now the user selects something, we should not crash.
- view_->OnSelectPopupMenuItem(-1);
+ view()->OnSelectPopupMenuItem(-1);
}
// An empty select should not cause a crash when clicked.
@@ -132,7 +137,7 @@ TEST_F(ExternalPopupMenuRemoveTest, RemoveOnChange) {
EXPECT_TRUE(SimulateElementClick(kSelectID));
// Select something, it causes the select to be removed from the page.
- view_->OnSelectPopupMenuItem(0);
+ view()->OnSelectPopupMenuItem(0);
// Just to check the soundness of the test, call SimulateElementClick again.
// It should return false as the select has been removed.
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index b175a5e..78df67c6 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -10,6 +10,7 @@
#include "chrome/test/base/render_view_test.h"
#include "content/common/native_web_keyboard_event.h"
#include "content/common/view_messages.h"
+#include "content/renderer/render_view_impl.h"
#include "net/base/net_errors.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
@@ -24,12 +25,19 @@ using WebKit::WebString;
using WebKit::WebTextDirection;
using WebKit::WebURLError;
+class RenderViewImplTest : public RenderViewTest {
+ public:
+ RenderViewImpl* view() {
+ return static_cast<RenderViewImpl*>(view_);
+ }
+};
+
// Test that we get form state change notifications when input fields change.
-TEST_F(RenderViewTest, OnNavStateChanged) {
+TEST_F(RenderViewImplTest, OnNavStateChanged) {
// Don't want any delay for form state sync changes. This will still post a
// message so updates will get coalesced, but as soon as we spin the message
// loop, it will generate an update.
- view_->set_send_content_state_immediately(true);
+ view()->set_send_content_state_immediately(true);
LoadHTML("<input type=\"text\" id=\"elt_text\"></input>");
@@ -48,7 +56,7 @@ TEST_F(RenderViewTest, OnNavStateChanged) {
// Test that we get the correct UpdateState message when we go back twice
// quickly without committing. Regression test for http://crbug.com/58082.
-TEST_F(RenderViewTest, LastCommittedUpdateState) {
+TEST_F(RenderViewImplTest, LastCommittedUpdateState) {
// Load page A.
LoadHTML("<div>Page A</div>");
@@ -102,7 +110,7 @@ TEST_F(RenderViewTest, LastCommittedUpdateState) {
params_C.pending_history_list_offset = 2;
params_C.page_id = 3;
params_C.state = state_C;
- view_->OnNavigate(params_C);
+ view()->OnNavigate(params_C);
ProcessPendingMessages();
render_thread_.sink().ClearMessages();
@@ -119,7 +127,7 @@ TEST_F(RenderViewTest, LastCommittedUpdateState) {
params_B.pending_history_list_offset = 1;
params_B.page_id = 2;
params_B.state = state_B;
- view_->OnNavigate(params_B);
+ view()->OnNavigate(params_B);
// Back to page A (page_id 1) and commit.
ViewMsg_Navigate_Params params;
@@ -130,7 +138,7 @@ TEST_F(RenderViewTest, LastCommittedUpdateState) {
params_B.pending_history_list_offset = 0;
params.page_id = 1;
params.state = state_A;
- view_->OnNavigate(params);
+ view()->OnNavigate(params);
ProcessPendingMessages();
// Now ensure that the UpdateState message we receive is consistent
@@ -150,18 +158,18 @@ TEST_F(RenderViewTest, LastCommittedUpdateState) {
// Test that the history_page_ids_ list can reveal when a stale back/forward
// navigation arrives from the browser and can be ignored. See
// http://crbug.com/86758.
-TEST_F(RenderViewTest, StaleNavigationsIgnored) {
+TEST_F(RenderViewImplTest, StaleNavigationsIgnored) {
// Load page A.
LoadHTML("<div>Page A</div>");
- EXPECT_EQ(1, view_->history_list_length_);
- EXPECT_EQ(0, view_->history_list_offset_);
- EXPECT_EQ(1, view_->history_page_ids_[0]);
+ EXPECT_EQ(1, view()->history_list_length_);
+ EXPECT_EQ(0, view()->history_list_offset_);
+ EXPECT_EQ(1, view()->history_page_ids_[0]);
// Load page B, which will trigger an UpdateState message for page A.
LoadHTML("<div>Page B</div>");
- EXPECT_EQ(2, view_->history_list_length_);
- EXPECT_EQ(1, view_->history_list_offset_);
- EXPECT_EQ(2, view_->history_page_ids_[1]);
+ EXPECT_EQ(2, view()->history_list_length_);
+ EXPECT_EQ(1, view()->history_list_offset_);
+ EXPECT_EQ(2, view()->history_page_ids_[1]);
// Check for a valid UpdateState message for page A.
const IPC::Message* msg_A = render_thread_.sink().GetUniqueMessageMatching(
@@ -182,14 +190,14 @@ TEST_F(RenderViewTest, StaleNavigationsIgnored) {
params_A.pending_history_list_offset = 0;
params_A.page_id = 1;
params_A.state = state_A;
- view_->OnNavigate(params_A);
+ view()->OnNavigate(params_A);
ProcessPendingMessages();
// A new navigation commits, clearing the forward history.
LoadHTML("<div>Page C</div>");
- EXPECT_EQ(2, view_->history_list_length_);
- EXPECT_EQ(1, view_->history_list_offset_);
- EXPECT_EQ(3, view_->history_page_ids_[1]);
+ EXPECT_EQ(2, view()->history_list_length_);
+ EXPECT_EQ(1, view()->history_list_offset_);
+ EXPECT_EQ(3, view()->history_page_ids_[1]);
// The browser then sends a stale navigation to B, which should be ignored.
ViewMsg_Navigate_Params params_B;
@@ -200,12 +208,12 @@ TEST_F(RenderViewTest, StaleNavigationsIgnored) {
params_B.pending_history_list_offset = 1;
params_B.page_id = 2;
params_B.state = state_A; // Doesn't matter, just has to be present.
- view_->OnNavigate(params_B);
+ view()->OnNavigate(params_B);
// State should be unchanged.
- EXPECT_EQ(2, view_->history_list_length_);
- EXPECT_EQ(1, view_->history_list_offset_);
- EXPECT_EQ(3, view_->history_page_ids_[1]);
+ EXPECT_EQ(2, view()->history_list_length_);
+ EXPECT_EQ(1, view()->history_list_offset_);
+ EXPECT_EQ(3, view()->history_page_ids_[1]);
}
// Test that we do not ignore navigations after the entry limit is reached,
@@ -214,18 +222,18 @@ TEST_F(RenderViewTest, StaleNavigationsIgnored) {
// not newer, than params.page_id. Use this as a cue that we should update the
// state and not treat it like a navigation to a cropped forward history item.
// See http://crbug.com/89798.
-TEST_F(RenderViewTest, DontIgnoreBackAfterNavEntryLimit) {
+TEST_F(RenderViewImplTest, DontIgnoreBackAfterNavEntryLimit) {
// Load page A.
LoadHTML("<div>Page A</div>");
- EXPECT_EQ(1, view_->history_list_length_);
- EXPECT_EQ(0, view_->history_list_offset_);
- EXPECT_EQ(1, view_->history_page_ids_[0]);
+ EXPECT_EQ(1, view()->history_list_length_);
+ EXPECT_EQ(0, view()->history_list_offset_);
+ EXPECT_EQ(1, view()->history_page_ids_[0]);
// Load page B, which will trigger an UpdateState message for page A.
LoadHTML("<div>Page B</div>");
- EXPECT_EQ(2, view_->history_list_length_);
- EXPECT_EQ(1, view_->history_list_offset_);
- EXPECT_EQ(2, view_->history_page_ids_[1]);
+ EXPECT_EQ(2, view()->history_list_length_);
+ EXPECT_EQ(1, view()->history_list_offset_);
+ EXPECT_EQ(2, view()->history_page_ids_[1]);
// Check for a valid UpdateState message for page A.
const IPC::Message* msg_A = render_thread_.sink().GetUniqueMessageMatching(
@@ -239,9 +247,9 @@ TEST_F(RenderViewTest, DontIgnoreBackAfterNavEntryLimit) {
// Load page C, which will trigger an UpdateState message for page B.
LoadHTML("<div>Page C</div>");
- EXPECT_EQ(3, view_->history_list_length_);
- EXPECT_EQ(2, view_->history_list_offset_);
- EXPECT_EQ(3, view_->history_page_ids_[2]);
+ EXPECT_EQ(3, view()->history_list_length_);
+ EXPECT_EQ(2, view()->history_list_offset_);
+ EXPECT_EQ(3, view()->history_page_ids_[2]);
// Check for a valid UpdateState message for page B.
const IPC::Message* msg_B = render_thread_.sink().GetUniqueMessageMatching(
@@ -264,22 +272,22 @@ TEST_F(RenderViewTest, DontIgnoreBackAfterNavEntryLimit) {
params_B.pending_history_list_offset = 0;
params_B.page_id = 2;
params_B.state = state_B;
- view_->OnNavigate(params_B);
+ view()->OnNavigate(params_B);
ProcessPendingMessages();
- EXPECT_EQ(2, view_->history_list_length_);
- EXPECT_EQ(0, view_->history_list_offset_);
- EXPECT_EQ(2, view_->history_page_ids_[0]);
+ EXPECT_EQ(2, view()->history_list_length_);
+ EXPECT_EQ(0, view()->history_list_offset_);
+ EXPECT_EQ(2, view()->history_page_ids_[0]);
}
// Test that our IME backend sends a notification message when the input focus
// changes.
-TEST_F(RenderViewTest, OnImeStateChanged) {
+TEST_F(RenderViewImplTest, OnImeStateChanged) {
// Enable our IME backend code.
- view_->OnSetInputMethodActive(true);
+ view()->OnSetInputMethodActive(true);
// Load an HTML page consisting of two input fields.
- view_->set_send_content_state_immediately(true);
+ view()->set_send_content_state_immediately(true);
LoadHTML("<html>"
"<head>"
"</head>"
@@ -300,7 +308,7 @@ TEST_F(RenderViewTest, OnImeStateChanged) {
// Update the IME status and verify if our IME backend sends an IPC message
// to activate IMEs.
- view_->UpdateInputMethod();
+ view()->UpdateInputMethod();
const IPC::Message* msg = render_thread_.sink().GetMessageAt(0);
EXPECT_TRUE(msg != NULL);
EXPECT_EQ(ViewHostMsg_ImeUpdateTextInputState::ID, msg->type());
@@ -318,7 +326,7 @@ TEST_F(RenderViewTest, OnImeStateChanged) {
// Update the IME status and verify if our IME backend sends an IPC message
// to de-activate IMEs.
- view_->UpdateInputMethod();
+ view()->UpdateInputMethod();
msg = render_thread_.sink().GetMessageAt(0);
EXPECT_TRUE(msg != NULL);
EXPECT_EQ(ViewHostMsg_ImeUpdateTextInputState::ID, msg->type());
@@ -338,7 +346,7 @@ TEST_F(RenderViewTest, OnImeStateChanged) {
// cases, this test should not only call IME-related functions in the
// RenderWidget class, but also call some RenderWidget members, e.g.
// ExecuteJavaScript(), RenderWidget::OnSetFocus(), etc.
-TEST_F(RenderViewTest, ImeComposition) {
+TEST_F(RenderViewImplTest, ImeComposition) {
enum ImeCommand {
IME_INITIALIZE,
IME_SETINPUTMODE,
@@ -404,8 +412,8 @@ TEST_F(RenderViewTest, ImeComposition) {
// Load an HTML page consisting of a content-editable <div> element,
// and move the input focus to the <div> element, where we can use
// IMEs.
- view_->OnSetInputMethodActive(ime_message->enable);
- view_->set_send_content_state_immediately(true);
+ view()->OnSetInputMethodActive(ime_message->enable);
+ view()->set_send_content_state_immediately(true);
LoadHTML("<html>"
"<head>"
"</head>"
@@ -418,16 +426,16 @@ TEST_F(RenderViewTest, ImeComposition) {
case IME_SETINPUTMODE:
// Activate (or deactivate) our IME back-end.
- view_->OnSetInputMethodActive(ime_message->enable);
+ view()->OnSetInputMethodActive(ime_message->enable);
break;
case IME_SETFOCUS:
// Update the window focus.
- view_->OnSetFocus(ime_message->enable);
+ view()->OnSetFocus(ime_message->enable);
break;
case IME_SETCOMPOSITION:
- view_->OnImeSetComposition(
+ view()->OnImeSetComposition(
WideToUTF16Hack(ime_message->ime_string),
std::vector<WebKit::WebCompositionUnderline>(),
ime_message->selection_start,
@@ -435,20 +443,21 @@ TEST_F(RenderViewTest, ImeComposition) {
break;
case IME_CONFIRMCOMPOSITION:
- view_->OnImeConfirmComposition(
+ view()->OnImeConfirmComposition(
WideToUTF16Hack(ime_message->ime_string));
break;
case IME_CANCELCOMPOSITION:
- view_->OnImeSetComposition(string16(),
- std::vector<WebKit::WebCompositionUnderline>(),
- 0, 0);
+ view()->OnImeSetComposition(
+ string16(),
+ std::vector<WebKit::WebCompositionUnderline>(),
+ 0, 0);
break;
}
// Update the status of our IME back-end.
// TODO(hbono): we should verify messages to be sent from the back-end.
- view_->UpdateInputMethod();
+ view()->UpdateInputMethod();
ProcessPendingMessages();
render_thread_.sink().ClearMessages();
@@ -465,12 +474,12 @@ TEST_F(RenderViewTest, ImeComposition) {
// Test that the RenderView::OnSetTextDirection() function can change the text
// direction of the selected input element.
-TEST_F(RenderViewTest, OnSetTextDirection) {
+TEST_F(RenderViewImplTest, OnSetTextDirection) {
// Load an HTML page consisting of a <textarea> element and a <div> element.
// This test changes the text direction of the <textarea> element, and
// writes the values of its 'dir' attribute and its 'direction' property to
// verify that the text direction is changed.
- view_->set_send_content_state_immediately(true);
+ view()->set_send_content_state_immediately(true);
LoadHTML("<html>"
"<head>"
"</head>"
@@ -491,7 +500,7 @@ TEST_F(RenderViewTest, OnSetTextDirection) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTextDirection); ++i) {
// Set the text direction of the <textarea> element.
ExecuteJavaScript("document.getElementById('test').focus();");
- view_->OnSetTextDirection(kTextDirection[i].direction);
+ view()->OnSetTextDirection(kTextDirection[i].direction);
// Write the values of its DOM 'dir' attribute and its CSS 'direction'
// property to the <div> element.
@@ -513,7 +522,7 @@ TEST_F(RenderViewTest, OnSetTextDirection) {
// Test that we can receive correct DOM events when we send input events
// through the RenderWidget::OnHandleInputEvent() function.
-TEST_F(RenderViewTest, OnHandleKeyboardEvent) {
+TEST_F(RenderViewImplTest, OnHandleKeyboardEvent) {
#if !defined(OS_MACOSX)
// Load an HTML page consisting of one <input> element and three
// contentediable <div> elements.
@@ -523,7 +532,7 @@ TEST_F(RenderViewTest, OnHandleKeyboardEvent) {
// TODO(hbono): <http://crbug.com/2215> Our WebKit port set |ev.metaKey| to
// true when pressing an alt key, i.e. the |ev.metaKey| value is not
// trustworthy. We will check the |ev.metaKey| value when this issue is fixed.
- view_->set_send_content_state_immediately(true);
+ view()->set_send_content_state_immediately(true);
LoadHTML("<html>"
"<head>"
"<title></title>"
@@ -661,7 +670,7 @@ TEST_F(RenderViewTest, OnHandleKeyboardEvent) {
// keyboard events through the RenderWidget::OnHandleInputEvent() function.
// This test is for preventing regressions caused only when we use non-US
// keyboards, such as Issue 10846.
-TEST_F(RenderViewTest, InsertCharacters) {
+TEST_F(RenderViewImplTest, InsertCharacters) {
#if !defined(OS_MACOSX)
static const struct {
MockKeyboard::Layout layout;
@@ -804,7 +813,7 @@ TEST_F(RenderViewTest, InsertCharacters) {
// This <div> element is used by the EditorClientImpl class to insert
// characters received through the RenderWidget::OnHandleInputEvent()
// function.
- view_->set_send_content_state_immediately(true);
+ view()->set_send_content_state_immediately(true);
LoadHTML("<html>"
"<head>"
"<title></title>"
@@ -882,7 +891,7 @@ TEST_F(RenderViewTest, InsertCharacters) {
}
// Crashy, http://crbug.com/53247.
-TEST_F(RenderViewTest, DISABLED_DidFailProvisionalLoadWithErrorForError) {
+TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) {
GetMainFrame()->enableViewSourceMode(true);
WebURLError error;
error.domain.fromUTF8("test_domain");
@@ -890,12 +899,12 @@ TEST_F(RenderViewTest, DISABLED_DidFailProvisionalLoadWithErrorForError) {
error.unreachableURL = GURL("http://foo");
WebFrame* web_frame = GetMainFrame();
// An error occurred.
- view_->didFailProvisionalLoad(web_frame, error);
+ view()->didFailProvisionalLoad(web_frame, error);
// Frame should exit view-source mode.
EXPECT_FALSE(web_frame->isViewSourceModeEnabled());
}
-TEST_F(RenderViewTest, DidFailProvisionalLoadWithErrorForCancellation) {
+TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) {
GetMainFrame()->enableViewSourceMode(true);
WebURLError error;
error.domain.fromUTF8("test_domain");
@@ -903,174 +912,174 @@ TEST_F(RenderViewTest, DidFailProvisionalLoadWithErrorForCancellation) {
error.unreachableURL = GURL("http://foo");
WebFrame* web_frame = GetMainFrame();
// A cancellation occurred.
- view_->didFailProvisionalLoad(web_frame, error);
+ view()->didFailProvisionalLoad(web_frame, error);
// Frame should stay in view-source mode.
EXPECT_TRUE(web_frame->isViewSourceModeEnabled());
}
// Regression test for http://crbug.com/41562
-TEST_F(RenderViewTest, UpdateTargetURLWithInvalidURL) {
+TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) {
const GURL invalid_gurl("http://");
- view_->setMouseOverURL(WebKit::WebURL(invalid_gurl));
- EXPECT_EQ(invalid_gurl, view_->target_url_);
+ view()->setMouseOverURL(WebKit::WebURL(invalid_gurl));
+ EXPECT_EQ(invalid_gurl, view()->target_url_);
}
-TEST_F(RenderViewTest, SetHistoryLengthAndPrune) {
+TEST_F(RenderViewImplTest, SetHistoryLengthAndPrune) {
int expected_page_id = -1;
// No history to merge and no committed pages.
- view_->OnSetHistoryLengthAndPrune(0, -1);
- EXPECT_EQ(0, view_->history_list_length_);
- EXPECT_EQ(-1, view_->history_list_offset_);
+ view()->OnSetHistoryLengthAndPrune(0, -1);
+ EXPECT_EQ(0, view()->history_list_length_);
+ EXPECT_EQ(-1, view()->history_list_offset_);
// History to merge and no committed pages.
- view_->OnSetHistoryLengthAndPrune(2, -1);
- EXPECT_EQ(2, view_->history_list_length_);
- EXPECT_EQ(1, view_->history_list_offset_);
- EXPECT_EQ(-1, view_->history_page_ids_[0]);
- EXPECT_EQ(-1, view_->history_page_ids_[1]);
+ view()->OnSetHistoryLengthAndPrune(2, -1);
+ EXPECT_EQ(2, view()->history_list_length_);
+ EXPECT_EQ(1, view()->history_list_offset_);
+ EXPECT_EQ(-1, view()->history_page_ids_[0]);
+ EXPECT_EQ(-1, view()->history_page_ids_[1]);
ClearHistory();
// No history to merge and a committed page to be kept.
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id = view_->page_id_;
- view_->OnSetHistoryLengthAndPrune(0, expected_page_id);
- EXPECT_EQ(1, view_->history_list_length_);
- EXPECT_EQ(0, view_->history_list_offset_);
- EXPECT_EQ(expected_page_id, view_->history_page_ids_[0]);
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id = view()->page_id_;
+ view()->OnSetHistoryLengthAndPrune(0, expected_page_id);
+ EXPECT_EQ(1, view()->history_list_length_);
+ EXPECT_EQ(0, view()->history_list_offset_);
+ EXPECT_EQ(expected_page_id, view()->history_page_ids_[0]);
ClearHistory();
// No history to merge and a committed page to be pruned.
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id = view_->page_id_;
- view_->OnSetHistoryLengthAndPrune(0, expected_page_id + 1);
- EXPECT_EQ(0, view_->history_list_length_);
- EXPECT_EQ(-1, view_->history_list_offset_);
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id = view()->page_id_;
+ view()->OnSetHistoryLengthAndPrune(0, expected_page_id + 1);
+ EXPECT_EQ(0, view()->history_list_length_);
+ EXPECT_EQ(-1, view()->history_list_offset_);
ClearHistory();
// No history to merge and a committed page that the browser was unaware of.
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id = view_->page_id_;
- view_->OnSetHistoryLengthAndPrune(0, -1);
- EXPECT_EQ(1, view_->history_list_length_);
- EXPECT_EQ(0, view_->history_list_offset_);
- EXPECT_EQ(expected_page_id, view_->history_page_ids_[0]);
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id = view()->page_id_;
+ view()->OnSetHistoryLengthAndPrune(0, -1);
+ EXPECT_EQ(1, view()->history_list_length_);
+ EXPECT_EQ(0, view()->history_list_offset_);
+ EXPECT_EQ(expected_page_id, view()->history_page_ids_[0]);
ClearHistory();
// History to merge and a committed page to be kept.
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id = view_->page_id_;
- view_->OnSetHistoryLengthAndPrune(2, expected_page_id);
- EXPECT_EQ(3, view_->history_list_length_);
- EXPECT_EQ(2, view_->history_list_offset_);
- EXPECT_EQ(-1, view_->history_page_ids_[0]);
- EXPECT_EQ(-1, view_->history_page_ids_[1]);
- EXPECT_EQ(expected_page_id, view_->history_page_ids_[2]);
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id = view()->page_id_;
+ view()->OnSetHistoryLengthAndPrune(2, expected_page_id);
+ EXPECT_EQ(3, view()->history_list_length_);
+ EXPECT_EQ(2, view()->history_list_offset_);
+ EXPECT_EQ(-1, view()->history_page_ids_[0]);
+ EXPECT_EQ(-1, view()->history_page_ids_[1]);
+ EXPECT_EQ(expected_page_id, view()->history_page_ids_[2]);
ClearHistory();
// History to merge and a committed page to be pruned.
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id = view_->page_id_;
- view_->OnSetHistoryLengthAndPrune(2, expected_page_id + 1);
- EXPECT_EQ(2, view_->history_list_length_);
- EXPECT_EQ(1, view_->history_list_offset_);
- EXPECT_EQ(-1, view_->history_page_ids_[0]);
- EXPECT_EQ(-1, view_->history_page_ids_[1]);
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id = view()->page_id_;
+ view()->OnSetHistoryLengthAndPrune(2, expected_page_id + 1);
+ EXPECT_EQ(2, view()->history_list_length_);
+ EXPECT_EQ(1, view()->history_list_offset_);
+ EXPECT_EQ(-1, view()->history_page_ids_[0]);
+ EXPECT_EQ(-1, view()->history_page_ids_[1]);
ClearHistory();
// History to merge and a committed page that the browser was unaware of.
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id = view_->page_id_;
- view_->OnSetHistoryLengthAndPrune(2, -1);
- EXPECT_EQ(3, view_->history_list_length_);
- EXPECT_EQ(2, view_->history_list_offset_);
- EXPECT_EQ(-1, view_->history_page_ids_[0]);
- EXPECT_EQ(-1, view_->history_page_ids_[1]);
- EXPECT_EQ(expected_page_id, view_->history_page_ids_[2]);
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id = view()->page_id_;
+ view()->OnSetHistoryLengthAndPrune(2, -1);
+ EXPECT_EQ(3, view()->history_list_length_);
+ EXPECT_EQ(2, view()->history_list_offset_);
+ EXPECT_EQ(-1, view()->history_page_ids_[0]);
+ EXPECT_EQ(-1, view()->history_page_ids_[1]);
+ EXPECT_EQ(expected_page_id, view()->history_page_ids_[2]);
ClearHistory();
int expected_page_id_2 = -1;
// No history to merge and two committed pages, both to be kept.
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id = view_->page_id_;
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id_2 = view_->page_id_;
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id = view()->page_id_;
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id_2 = view()->page_id_;
EXPECT_GT(expected_page_id_2, expected_page_id);
- view_->OnSetHistoryLengthAndPrune(0, expected_page_id);
- EXPECT_EQ(2, view_->history_list_length_);
- EXPECT_EQ(1, view_->history_list_offset_);
- EXPECT_EQ(expected_page_id, view_->history_page_ids_[0]);
- EXPECT_EQ(expected_page_id_2, view_->history_page_ids_[1]);
+ view()->OnSetHistoryLengthAndPrune(0, expected_page_id);
+ EXPECT_EQ(2, view()->history_list_length_);
+ EXPECT_EQ(1, view()->history_list_offset_);
+ EXPECT_EQ(expected_page_id, view()->history_page_ids_[0]);
+ EXPECT_EQ(expected_page_id_2, view()->history_page_ids_[1]);
ClearHistory();
// No history to merge and two committed pages, and only the second is kept.
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id = view_->page_id_;
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id_2 = view_->page_id_;
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id = view()->page_id_;
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id_2 = view()->page_id_;
EXPECT_GT(expected_page_id_2, expected_page_id);
- view_->OnSetHistoryLengthAndPrune(0, expected_page_id_2);
- EXPECT_EQ(1, view_->history_list_length_);
- EXPECT_EQ(0, view_->history_list_offset_);
- EXPECT_EQ(expected_page_id_2, view_->history_page_ids_[0]);
+ view()->OnSetHistoryLengthAndPrune(0, expected_page_id_2);
+ EXPECT_EQ(1, view()->history_list_length_);
+ EXPECT_EQ(0, view()->history_list_offset_);
+ EXPECT_EQ(expected_page_id_2, view()->history_page_ids_[0]);
ClearHistory();
// No history to merge and two committed pages, both of which the browser was
// unaware of.
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id = view_->page_id_;
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id_2 = view_->page_id_;
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id = view()->page_id_;
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id_2 = view()->page_id_;
EXPECT_GT(expected_page_id_2, expected_page_id);
- view_->OnSetHistoryLengthAndPrune(0, -1);
- EXPECT_EQ(2, view_->history_list_length_);
- EXPECT_EQ(1, view_->history_list_offset_);
- EXPECT_EQ(expected_page_id, view_->history_page_ids_[0]);
- EXPECT_EQ(expected_page_id_2, view_->history_page_ids_[1]);
+ view()->OnSetHistoryLengthAndPrune(0, -1);
+ EXPECT_EQ(2, view()->history_list_length_);
+ EXPECT_EQ(1, view()->history_list_offset_);
+ EXPECT_EQ(expected_page_id, view()->history_page_ids_[0]);
+ EXPECT_EQ(expected_page_id_2, view()->history_page_ids_[1]);
ClearHistory();
// History to merge and two committed pages, both to be kept.
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id = view_->page_id_;
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id_2 = view_->page_id_;
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id = view()->page_id_;
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id_2 = view()->page_id_;
EXPECT_GT(expected_page_id_2, expected_page_id);
- view_->OnSetHistoryLengthAndPrune(2, expected_page_id);
- EXPECT_EQ(4, view_->history_list_length_);
- EXPECT_EQ(3, view_->history_list_offset_);
- EXPECT_EQ(-1, view_->history_page_ids_[0]);
- EXPECT_EQ(-1, view_->history_page_ids_[1]);
- EXPECT_EQ(expected_page_id, view_->history_page_ids_[2]);
- EXPECT_EQ(expected_page_id_2, view_->history_page_ids_[3]);
+ view()->OnSetHistoryLengthAndPrune(2, expected_page_id);
+ EXPECT_EQ(4, view()->history_list_length_);
+ EXPECT_EQ(3, view()->history_list_offset_);
+ EXPECT_EQ(-1, view()->history_page_ids_[0]);
+ EXPECT_EQ(-1, view()->history_page_ids_[1]);
+ EXPECT_EQ(expected_page_id, view()->history_page_ids_[2]);
+ EXPECT_EQ(expected_page_id_2, view()->history_page_ids_[3]);
ClearHistory();
// History to merge and two committed pages, and only the second is kept.
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id = view_->page_id_;
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id_2 = view_->page_id_;
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id = view()->page_id_;
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id_2 = view()->page_id_;
EXPECT_GT(expected_page_id_2, expected_page_id);
- view_->OnSetHistoryLengthAndPrune(2, expected_page_id_2);
- EXPECT_EQ(3, view_->history_list_length_);
- EXPECT_EQ(2, view_->history_list_offset_);
- EXPECT_EQ(-1, view_->history_page_ids_[0]);
- EXPECT_EQ(-1, view_->history_page_ids_[1]);
- EXPECT_EQ(expected_page_id_2, view_->history_page_ids_[2]);
+ view()->OnSetHistoryLengthAndPrune(2, expected_page_id_2);
+ EXPECT_EQ(3, view()->history_list_length_);
+ EXPECT_EQ(2, view()->history_list_offset_);
+ EXPECT_EQ(-1, view()->history_page_ids_[0]);
+ EXPECT_EQ(-1, view()->history_page_ids_[1]);
+ EXPECT_EQ(expected_page_id_2, view()->history_page_ids_[2]);
ClearHistory();
// History to merge and two committed pages, both of which the browser was
// unaware of.
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id = view_->page_id_;
- view_->didCommitProvisionalLoad(GetMainFrame(), true);
- expected_page_id_2 = view_->page_id_;
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id = view()->page_id_;
+ view()->didCommitProvisionalLoad(GetMainFrame(), true);
+ expected_page_id_2 = view()->page_id_;
EXPECT_GT(expected_page_id_2, expected_page_id);
- view_->OnSetHistoryLengthAndPrune(2, -1);
- EXPECT_EQ(4, view_->history_list_length_);
- EXPECT_EQ(3, view_->history_list_offset_);
- EXPECT_EQ(-1, view_->history_page_ids_[0]);
- EXPECT_EQ(-1, view_->history_page_ids_[1]);
- EXPECT_EQ(expected_page_id, view_->history_page_ids_[2]);
- EXPECT_EQ(expected_page_id_2, view_->history_page_ids_[3]);
+ view()->OnSetHistoryLengthAndPrune(2, -1);
+ EXPECT_EQ(4, view()->history_list_length_);
+ EXPECT_EQ(3, view()->history_list_offset_);
+ EXPECT_EQ(-1, view()->history_page_ids_[0]);
+ EXPECT_EQ(-1, view()->history_page_ids_[1]);
+ EXPECT_EQ(expected_page_id, view()->history_page_ids_[2]);
+ EXPECT_EQ(expected_page_id_2, view()->history_page_ids_[3]);
}
diff --git a/content/renderer/render_view_browsertest_mac.mm b/content/renderer/render_view_browsertest_mac.mm
index 1d3459b..8784c2c 100644
--- a/content/renderer/render_view_browsertest_mac.mm
+++ b/content/renderer/render_view_browsertest_mac.mm
@@ -6,6 +6,7 @@
#include "base/string16.h"
#include "chrome/test/base/render_view_test.h"
#include "content/common/native_web_keyboard_event.h"
+#include "content/renderer/render_view_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
#include <Cocoa/Cocoa.h>
@@ -82,7 +83,9 @@ TEST_F(RenderViewTest, MacTestCmdUp) {
WebPreferences prefs;
prefs.enable_scroll_animator = false;
- view_->OnUpdateWebPreferences(prefs);
+
+ RenderViewImpl* view = static_cast<RenderViewImpl*>(view_);
+ view->OnUpdateWebPreferences(prefs);
const int kMaxOutputCharacters = 1024;
string16 output;
@@ -93,13 +96,13 @@ TEST_F(RenderViewTest, MacTestCmdUp) {
// First test when javascript does not eat keypresses -- should scroll.
sprintf(htmlBuffer, kRawHtml, "true");
- view_->set_send_content_state_immediately(true);
+ view->set_send_content_state_immediately(true);
LoadHTML(htmlBuffer);
render_thread_.sink().ClearMessages();
const char* kArrowDownScrollDown =
"40,false,false,true,false\n1936\np1\n\np2";
- view_->OnSetEditCommandsForNextKeyEvent(
+ view->OnSetEditCommandsForNextKeyEvent(
EditCommands(1, EditCommand("moveToEndOfDocument", "")));
SendNativeKeyEvent(NativeWebKeyboardEvent(arrowDownKeyDown));
ProcessPendingMessages();
@@ -108,7 +111,7 @@ TEST_F(RenderViewTest, MacTestCmdUp) {
const char* kArrowUpScrollUp =
"38,false,false,true,false\n0\np1\n\np2";
- view_->OnSetEditCommandsForNextKeyEvent(
+ view->OnSetEditCommandsForNextKeyEvent(
EditCommands(1, EditCommand("moveToBeginningOfDocument", "")));
SendNativeKeyEvent(NativeWebKeyboardEvent(arrowUpKeyDown));
ProcessPendingMessages();
@@ -118,13 +121,13 @@ TEST_F(RenderViewTest, MacTestCmdUp) {
// Now let javascript eat the key events -- no scrolling should happen
sprintf(htmlBuffer, kRawHtml, "false");
- view_->set_send_content_state_immediately(true);
+ view->set_send_content_state_immediately(true);
LoadHTML(htmlBuffer);
render_thread_.sink().ClearMessages();
const char* kArrowDownNoScroll =
"40,false,false,true,false\np1\n\np2";
- view_->OnSetEditCommandsForNextKeyEvent(
+ view->OnSetEditCommandsForNextKeyEvent(
EditCommands(1, EditCommand("moveToEndOfDocument", "")));
SendNativeKeyEvent(NativeWebKeyboardEvent(arrowDownKeyDown));
ProcessPendingMessages();
@@ -133,7 +136,7 @@ TEST_F(RenderViewTest, MacTestCmdUp) {
const char* kArrowUpNoScroll =
"38,false,false,true,false\np1\n\np2";
- view_->OnSetEditCommandsForNextKeyEvent(
+ view->OnSetEditCommandsForNextKeyEvent(
EditCommands(1, EditCommand("moveToBeginningOfDocument", "")));
SendNativeKeyEvent(NativeWebKeyboardEvent(arrowUpKeyDown));
ProcessPendingMessages();
diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
index d204a5f..c8cc69a 100644
--- a/content/renderer/render_view_impl.h
+++ b/content/renderer/render_view_impl.h
@@ -646,22 +646,23 @@ class RenderViewImpl : public RenderWidget,
FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange);
FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase);
FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, ShowPopupThenNavigate);
- FRIEND_TEST_ALL_PREFIXES(RenderViewTest, DontIgnoreBackAfterNavEntryLimit);
- FRIEND_TEST_ALL_PREFIXES(RenderViewTest, ImeComposition);
- FRIEND_TEST_ALL_PREFIXES(RenderViewTest, InsertCharacters);
- FRIEND_TEST_ALL_PREFIXES(RenderViewTest, JSBlockSentAfterPageLoad);
- FRIEND_TEST_ALL_PREFIXES(RenderViewTest, LastCommittedUpdateState);
- FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnHandleKeyboardEvent);
- FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnImeStateChanged);
- FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnNavStateChanged);
- FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnSetTextDirection);
- FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnUpdateWebPreferences);
- FRIEND_TEST_ALL_PREFIXES(RenderViewTest, StaleNavigationsIgnored);
- FRIEND_TEST_ALL_PREFIXES(RenderViewTest, UpdateTargetURLWithInvalidURL);
+ FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
+ DontIgnoreBackAfterNavEntryLimit);
+ FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ImeComposition);
+ FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, InsertCharacters);
+ FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, JSBlockSentAfterPageLoad);
+ FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, LastCommittedUpdateState);
+ FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnHandleKeyboardEvent);
+ FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnImeStateChanged);
+ FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnNavStateChanged);
+ FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnSetTextDirection);
+ FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnUpdateWebPreferences);
+ FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, StaleNavigationsIgnored);
+ FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, UpdateTargetURLWithInvalidURL);
#if defined(OS_MACOSX)
FRIEND_TEST_ALL_PREFIXES(RenderViewTest, MacTestCmdUp);
#endif
- FRIEND_TEST_ALL_PREFIXES(RenderViewTest, SetHistoryLengthAndPrune);
+ FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SetHistoryLengthAndPrune);
typedef std::map<GURL, double> HostZoomLevels;
diff --git a/content/test/render_widget_browsertest.cc b/content/test/render_widget_browsertest.cc
index 62ccd72..0ac6637 100644
--- a/content/test/render_widget_browsertest.cc
+++ b/content/test/render_widget_browsertest.cc
@@ -10,6 +10,7 @@
#include "base/memory/ref_counted_memory.h"
#include "base/stringprintf.h"
#include "content/common/view_messages.h"
+#include "content/renderer/render_view_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
@@ -46,8 +47,9 @@ void RenderWidgetTest::ResizeAndPaint(const gfx::Size& page_size,
// be closed and the handle will no longer be valid.
scoped_ptr<TransportDIB> mapped_pixels(TransportDIB::Map(pixels->handle()));
- view_->OnMsgPaintAtSize(pixels->handle(), g_sequence_num, page_size,
- desired_size);
+ RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
+ impl->OnMsgPaintAtSize(pixels->handle(), g_sequence_num, page_size,
+ desired_size);
ProcessPendingMessages();
const IPC::Message* msg = render_thread_.sink().GetUniqueMessageMatching(
ViewHostMsg_PaintAtSize_ACK::ID);
@@ -74,7 +76,7 @@ void RenderWidgetTest::TestResizeAndPaint() {
"<html><body><div style='position: absolute; top: %d; left: "
"%d; background-color: red;'>Hello World</div></body></html>",
kTextPositionY, kTextPositionX).c_str());
- WebKit::WebSize old_size = view_->webview()->size();
+ WebKit::WebSize old_size = view_->GetWebView()->size();
SkBitmap bitmap;
// If we re-size the view to something smaller than where the 'Hello World'
@@ -83,7 +85,7 @@ void RenderWidgetTest::TestResizeAndPaint() {
gfx::Size size(kSmallWidth, kSmallHeight);
ResizeAndPaint(size, size, &bitmap);
// Make sure that the view has been re-sized to its old size.
- EXPECT_TRUE(old_size == view_->webview()->size());
+ EXPECT_TRUE(old_size == view_->GetWebView()->size());
EXPECT_EQ(kSmallWidth, bitmap.width());
EXPECT_EQ(kSmallHeight, bitmap.height());
EXPECT_FALSE(ImageContainsColor(bitmap, kRedARGB));
@@ -93,7 +95,7 @@ void RenderWidgetTest::TestResizeAndPaint() {
// Hence, the snapshot should contain some red.
size.SetSize(kLargeWidth, kLargeHeight);
ResizeAndPaint(size, size, &bitmap);
- EXPECT_TRUE(old_size == view_->webview()->size());
+ EXPECT_TRUE(old_size == view_->GetWebView()->size());
EXPECT_EQ(kLargeWidth, bitmap.width());
EXPECT_EQ(kLargeHeight, bitmap.height());
EXPECT_TRUE(ImageContainsColor(bitmap, kRedARGB));
@@ -102,7 +104,7 @@ void RenderWidgetTest::TestResizeAndPaint() {
// should still see the 'Hello World' message since the view size is
// still large enough.
ResizeAndPaint(size, gfx::Size(kSmallWidth, kSmallHeight), &bitmap);
- EXPECT_TRUE(old_size == view_->webview()->size());
+ EXPECT_TRUE(old_size == view_->GetWebView()->size());
EXPECT_EQ(kSmallWidth, bitmap.width());
EXPECT_EQ(kSmallHeight, bitmap.height());
EXPECT_TRUE(ImageContainsColor(bitmap, kRedARGB));