| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // We should have gotten two different types of start messages in the | 98 // We should have gotten two different types of start messages in the |
| 99 // following order. | 99 // following order. |
| 100 ASSERT_EQ((size_t)2, render_thread_.sink().message_count()); | 100 ASSERT_EQ((size_t)2, render_thread_.sink().message_count()); |
| 101 const IPC::Message* msg = render_thread_.sink().GetMessageAt(0); | 101 const IPC::Message* msg = render_thread_.sink().GetMessageAt(0); |
| 102 EXPECT_EQ(ViewHostMsg_DidStartLoading::ID, msg->type()); | 102 EXPECT_EQ(ViewHostMsg_DidStartLoading::ID, msg->type()); |
| 103 | 103 |
| 104 msg = render_thread_.sink().GetMessageAt(1); | 104 msg = render_thread_.sink().GetMessageAt(1); |
| 105 EXPECT_EQ(ViewHostMsg_DidStartProvisionalLoadForFrame::ID, msg->type()); | 105 EXPECT_EQ(ViewHostMsg_DidStartProvisionalLoadForFrame::ID, msg->type()); |
| 106 ViewHostMsg_DidStartProvisionalLoadForFrame::Param start_params; | 106 ViewHostMsg_DidStartProvisionalLoadForFrame::Param start_params; |
| 107 ViewHostMsg_DidStartProvisionalLoadForFrame::Read(msg, &start_params); | 107 ViewHostMsg_DidStartProvisionalLoadForFrame::Read(msg, &start_params); |
| 108 EXPECT_EQ(GURL("chrome://chromewebdata/"), start_params.b); | 108 EXPECT_EQ(GURL("chrome-ui://chromewebdata/"), start_params.b); |
| 109 } | 109 } |
| 110 | 110 |
| 111 // Test that we get form state change notifications when input fields change. | 111 // Test that we get form state change notifications when input fields change. |
| 112 TEST_F(RenderViewTest, OnNavStateChanged) { | 112 TEST_F(RenderViewTest, OnNavStateChanged) { |
| 113 // Don't want any delay for form state sync changes. This will still post a | 113 // Don't want any delay for form state sync changes. This will still post a |
| 114 // message so updates will get coalesced, but as soon as we spin the message | 114 // message so updates will get coalesced, but as soon as we spin the message |
| 115 // loop, it will generate an update. | 115 // loop, it will generate an update. |
| 116 view_->set_delay_seconds_for_form_state_sync(0); | 116 view_->set_delay_seconds_for_form_state_sync(0); |
| 117 | 117 |
| 118 LoadHTML("<input type=\"text\" id=\"elt_text\"></input>"); | 118 LoadHTML("<input type=\"text\" id=\"elt_text\"></input>"); |
| 119 | 119 |
| 120 // We should NOT have gotten a form state change notification yet. | 120 // We should NOT have gotten a form state change notification yet. |
| 121 EXPECT_FALSE(render_thread_.sink().GetFirstMessageMatching( | 121 EXPECT_FALSE(render_thread_.sink().GetFirstMessageMatching( |
| 122 ViewHostMsg_UpdateState::ID)); | 122 ViewHostMsg_UpdateState::ID)); |
| 123 render_thread_.sink().ClearMessages(); | 123 render_thread_.sink().ClearMessages(); |
| 124 | 124 |
| 125 // Change the value of the input. We should have gotten an update state | 125 // Change the value of the input. We should have gotten an update state |
| 126 // notification. We need to spin the message loop to catch this update. | 126 // notification. We need to spin the message loop to catch this update. |
| 127 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';"); | 127 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';"); |
| 128 ProcessPendingMessages(); | 128 ProcessPendingMessages(); |
| 129 EXPECT_TRUE(render_thread_.sink().GetUniqueMessageMatching( | 129 EXPECT_TRUE(render_thread_.sink().GetUniqueMessageMatching( |
| 130 ViewHostMsg_UpdateState::ID)); | 130 ViewHostMsg_UpdateState::ID)); |
| 131 } | 131 } |
| OLD | NEW |