OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 5 #include "base/basictypes.h" |
6 | 6 |
7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "content/common/intents_messages.h" | |
11 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
12 #include "content/public/browser/native_web_keyboard_event.h" | 11 #include "content/public/browser/native_web_keyboard_event.h" |
13 #include "content/public/browser/web_ui_controller_factory.h" | 12 #include "content/public/browser/web_ui_controller_factory.h" |
14 #include "content/public/common/bindings_policy.h" | 13 #include "content/public/common/bindings_policy.h" |
15 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
16 #include "content/public/test/render_view_test.h" | 15 #include "content/public/test/render_view_test.h" |
17 #include "content/renderer/render_view_impl.h" | 16 #include "content/renderer/render_view_impl.h" |
18 #include "content/shell/shell_content_browser_client.h" | 17 #include "content/shell/shell_content_browser_client.h" |
19 #include "content/shell/shell_content_client.h" | 18 #include "content/shell/shell_content_client.h" |
20 #include "content/test/mock_keyboard.h" | 19 #include "content/test/mock_keyboard.h" |
21 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "third_party/WebKit/Source/Platform/chromium/public/WebData.h" | 22 #include "third_party/WebKit/Source/Platform/chromium/public/WebData.h" |
24 #include "third_party/WebKit/Source/Platform/chromium/public/WebHTTPBody.h" | 23 #include "third_party/WebKit/Source/Platform/chromium/public/WebHTTPBody.h" |
25 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 24 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
26 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h" | 25 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h" |
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" |
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentServiceInfo.
h" | |
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" |
31 #include "ui/base/keycodes/keyboard_codes.h" | 29 #include "ui/base/keycodes/keyboard_codes.h" |
32 #include "ui/base/range/range.h" | 30 #include "ui/base/range/range.h" |
33 #include "ui/gfx/codec/jpeg_codec.h" | 31 #include "ui/gfx/codec/jpeg_codec.h" |
34 #include "webkit/glue/glue_serialize.h" | 32 #include "webkit/glue/glue_serialize.h" |
35 #include "webkit/glue/web_io_operators.h" | 33 #include "webkit/glue/web_io_operators.h" |
36 | 34 |
37 #if defined(OS_LINUX) && !defined(USE_AURA) | 35 #if defined(OS_LINUX) && !defined(USE_AURA) |
38 #include "ui/base/gtk/event_synthesis_gtk.h" | 36 #include "ui/base/gtk/event_synthesis_gtk.h" |
(...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 EXPECT_GT(expected_page_id_2, expected_page_id); | 1574 EXPECT_GT(expected_page_id_2, expected_page_id); |
1577 view()->OnSetHistoryLengthAndPrune(2, -1); | 1575 view()->OnSetHistoryLengthAndPrune(2, -1); |
1578 EXPECT_EQ(4, view()->history_list_length_); | 1576 EXPECT_EQ(4, view()->history_list_length_); |
1579 EXPECT_EQ(3, view()->history_list_offset_); | 1577 EXPECT_EQ(3, view()->history_list_offset_); |
1580 EXPECT_EQ(-1, view()->history_page_ids_[0]); | 1578 EXPECT_EQ(-1, view()->history_page_ids_[0]); |
1581 EXPECT_EQ(-1, view()->history_page_ids_[1]); | 1579 EXPECT_EQ(-1, view()->history_page_ids_[1]); |
1582 EXPECT_EQ(expected_page_id, view()->history_page_ids_[2]); | 1580 EXPECT_EQ(expected_page_id, view()->history_page_ids_[2]); |
1583 EXPECT_EQ(expected_page_id_2, view()->history_page_ids_[3]); | 1581 EXPECT_EQ(expected_page_id_2, view()->history_page_ids_[3]); |
1584 } | 1582 } |
1585 | 1583 |
1586 #if defined(ENABLE_WEB_INTENTS) | |
1587 TEST_F(RenderViewImplTest, FindTitleForIntentsPage) { | |
1588 view()->set_send_content_state_immediately(true); | |
1589 LoadHTML("<html><head><title>title</title>" | |
1590 "<intent action=\"a\" type=\"t\"></intent></head></html>"); | |
1591 WebKit::WebIntentServiceInfo service; | |
1592 service.setAction(ASCIIToUTF16("a")); | |
1593 service.setType(ASCIIToUTF16("t")); | |
1594 view()->registerIntentService(GetMainFrame(), service); | |
1595 ProcessPendingMessages(); | |
1596 | |
1597 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( | |
1598 IntentsHostMsg_RegisterIntentService::ID)); | |
1599 const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching( | |
1600 IntentsHostMsg_RegisterIntentService::ID); | |
1601 ASSERT_TRUE(msg); | |
1602 webkit_glue::WebIntentServiceData service_data; | |
1603 bool user_gesture = true; | |
1604 IntentsHostMsg_RegisterIntentService::Read(msg, &service_data, &user_gesture); | |
1605 EXPECT_EQ(ASCIIToUTF16("a"), service_data.action); | |
1606 EXPECT_EQ(ASCIIToUTF16("t"), service_data.type); | |
1607 EXPECT_EQ(ASCIIToUTF16("title"), service_data.title); | |
1608 EXPECT_FALSE(user_gesture); | |
1609 } | |
1610 #endif | |
1611 | |
1612 TEST_F(RenderViewImplTest, ContextMenu) { | 1584 TEST_F(RenderViewImplTest, ContextMenu) { |
1613 LoadHTML("<div>Page A</div>"); | 1585 LoadHTML("<div>Page A</div>"); |
1614 | 1586 |
1615 // Create a right click in the center of the iframe. (I'm hoping this will | 1587 // Create a right click in the center of the iframe. (I'm hoping this will |
1616 // make this a bit more robust in case of some other formatting or other bug.) | 1588 // make this a bit more robust in case of some other formatting or other bug.) |
1617 WebMouseEvent mouse_event; | 1589 WebMouseEvent mouse_event; |
1618 mouse_event.type = WebInputEvent::MouseDown; | 1590 mouse_event.type = WebInputEvent::MouseDown; |
1619 mouse_event.button = WebMouseEvent::ButtonRight; | 1591 mouse_event.button = WebMouseEvent::ButtonRight; |
1620 mouse_event.x = 250; | 1592 mouse_event.x = 250; |
1621 mouse_event.y = 250; | 1593 mouse_event.y = 250; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1844 | 1816 |
1845 // Copy the document content to std::wstring and compare with the | 1817 // Copy the document content to std::wstring and compare with the |
1846 // expected result. | 1818 // expected result. |
1847 const int kMaxOutputCharacters = 256; | 1819 const int kMaxOutputCharacters = 256; |
1848 std::wstring output = UTF16ToWideHack( | 1820 std::wstring output = UTF16ToWideHack( |
1849 GetMainFrame()->contentAsText(kMaxOutputCharacters)); | 1821 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
1850 EXPECT_EQ(output, L"hello \n\nworld"); | 1822 EXPECT_EQ(output, L"hello \n\nworld"); |
1851 } | 1823 } |
1852 | 1824 |
1853 } // namespace content | 1825 } // namespace content |
OLD | NEW |