OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/scoped_ptr.h" | 5 #include "base/scoped_ptr.h" |
6 #include "chrome/renderer/mock_render_process.h" | 6 #include "chrome/renderer/mock_render_process.h" |
7 #include "chrome/renderer/mock_render_thread.h" | 7 #include "chrome/renderer/mock_render_thread.h" |
8 #include "chrome/renderer/render_view.h" | 8 #include "chrome/renderer/render_view.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "webkit/glue/webframe.h" | 10 #include "webkit/glue/webframe.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } // namespace | 87 } // namespace |
88 | 88 |
89 TEST_F(RenderViewTest, OnLoadAlternateHTMLText) { | 89 TEST_F(RenderViewTest, OnLoadAlternateHTMLText) { |
90 // Test a new navigation. | 90 // Test a new navigation. |
91 GURL test_url("http://www.google.com/some_test_url"); | 91 GURL test_url("http://www.google.com/some_test_url"); |
92 view_->OnLoadAlternateHTMLText("<html></html>", true, test_url, | 92 view_->OnLoadAlternateHTMLText("<html></html>", true, test_url, |
93 std::string()); | 93 std::string()); |
94 | 94 |
95 // We should have gotten two different types of start messages in the | 95 // We should have gotten two different types of start messages in the |
96 // following order. | 96 // following order. |
97 ASSERT_EQ(2, render_thread_.message_count()); | 97 ASSERT_EQ(2, render_thread_.sink().message_count()); |
98 const IPC::Message* msg = render_thread_.GetMessageAt(0); | 98 const IPC::Message* msg = render_thread_.sink().GetMessageAt(0); |
99 EXPECT_EQ(ViewHostMsg_DidStartLoading::ID, msg->type()); | 99 EXPECT_EQ(ViewHostMsg_DidStartLoading::ID, msg->type()); |
100 | 100 |
101 msg = render_thread_.GetMessageAt(1); | 101 msg = render_thread_.sink().GetMessageAt(1); |
102 EXPECT_EQ(ViewHostMsg_DidStartProvisionalLoadForFrame::ID, msg->type()); | 102 EXPECT_EQ(ViewHostMsg_DidStartProvisionalLoadForFrame::ID, msg->type()); |
103 ViewHostMsg_DidStartProvisionalLoadForFrame::Param start_params; | 103 ViewHostMsg_DidStartProvisionalLoadForFrame::Param start_params; |
104 ViewHostMsg_DidStartProvisionalLoadForFrame::Read(msg, &start_params); | 104 ViewHostMsg_DidStartProvisionalLoadForFrame::Read(msg, &start_params); |
105 EXPECT_EQ(GURL("chrome://chromewebdata/"), start_params.b); | 105 EXPECT_EQ(GURL("chrome://chromewebdata/"), start_params.b); |
106 } | 106 } |
107 | 107 |
108 // Test that we get form state change notifications when input fields change. | 108 // Test that we get form state change notifications when input fields change. |
109 TEST_F(RenderViewTest, OnNavStateChanged) { | 109 TEST_F(RenderViewTest, OnNavStateChanged) { |
110 // Don't want any delay for form state sync changes. This will still post a | 110 // Don't want any delay for form state sync changes. This will still post a |
111 // message so updates will get coalesced, but as soon as we spin the message | 111 // message so updates will get coalesced, but as soon as we spin the message |
112 // loop, it will generate an update. | 112 // loop, it will generate an update. |
113 view_->set_delay_seconds_for_form_state_sync(0); | 113 view_->set_delay_seconds_for_form_state_sync(0); |
114 | 114 |
115 LoadHTML("<input type=\"text\" id=\"elt_text\"></input>"); | 115 LoadHTML("<input type=\"text\" id=\"elt_text\"></input>"); |
116 | 116 |
117 // We should NOT have gotten a form state change notification yet. | 117 // We should NOT have gotten a form state change notification yet. |
118 EXPECT_FALSE(render_thread_.GetFirstMessageMatching( | 118 EXPECT_FALSE(render_thread_.sink().GetFirstMessageMatching( |
119 ViewHostMsg_UpdateState::ID)); | 119 ViewHostMsg_UpdateState::ID)); |
120 render_thread_.ClearMessages(); | 120 render_thread_.sink().ClearMessages(); |
121 | 121 |
122 // Change the value of the input. We should have gotten an update state | 122 // Change the value of the input. We should have gotten an update state |
123 // notification. We need to spin the message loop to catch this update. | 123 // notification. We need to spin the message loop to catch this update. |
124 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';"); | 124 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';"); |
125 ProcessPendingMessages(); | 125 ProcessPendingMessages(); |
126 EXPECT_TRUE(render_thread_.GetUniqueMessageMatching( | 126 EXPECT_TRUE(render_thread_.sink().GetUniqueMessageMatching( |
127 ViewHostMsg_UpdateState::ID)); | 127 ViewHostMsg_UpdateState::ID)); |
128 } | 128 } |
OLD | NEW |