| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/gfx/codec/jpeg_codec.h" | 5 #include "app/gfx/codec/jpeg_codec.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
| 8 #include "chrome/common/native_web_keyboard_event.h" | 8 #include "chrome/common/native_web_keyboard_event.h" |
| 9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
| 10 #include "chrome/renderer/print_web_view_helper.h" | 10 #include "chrome/renderer/print_web_view_helper.h" |
| 11 #include "chrome/test/render_view_test.h" | 11 #include "chrome/test/render_view_test.h" |
| 12 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
| 13 #include "printing/image.h" | 13 #include "printing/image.h" |
| 14 #include "printing/native_metafile.h" | 14 #include "printing/native_metafile.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" | 16 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
| 17 #include "third_party/WebKit/WebKit/chromium/public/WebURLError.h" | 17 #include "third_party/WebKit/WebKit/chromium/public/WebURLError.h" |
| 18 | 18 |
| 19 using WebKit::WebCompositionCommand; | 19 using WebKit::WebCompositionCommand; |
| 20 using WebKit::WebFrame; | 20 using WebKit::WebFrame; |
| 21 using WebKit::WebString; | 21 using WebKit::WebString; |
| 22 using WebKit::WebTextDirection; | 22 using WebKit::WebTextDirection; |
| 23 using WebKit::WebURLError; | 23 using WebKit::WebURLError; |
| 24 | 24 |
| 25 #if !defined(OS_LINUX) |
| 25 static WebCompositionCommand ToCompositionCommand(int string_type) { | 26 static WebCompositionCommand ToCompositionCommand(int string_type) { |
| 26 switch (string_type) { | 27 switch (string_type) { |
| 27 default: | 28 default: |
| 28 NOTREACHED(); | 29 NOTREACHED(); |
| 29 case -1: | 30 case -1: |
| 30 return WebKit::WebCompositionCommandDiscard; | 31 return WebKit::WebCompositionCommandDiscard; |
| 31 case 0: | 32 case 0: |
| 32 return WebKit::WebCompositionCommandSet; | 33 return WebKit::WebCompositionCommandSet; |
| 33 case 1: | 34 case 1: |
| 34 return WebKit::WebCompositionCommandConfirm; | 35 return WebKit::WebCompositionCommandConfirm; |
| 35 } | 36 } |
| 36 } | 37 } |
| 38 #endif |
| 37 | 39 |
| 38 TEST_F(RenderViewTest, OnLoadAlternateHTMLText) { | 40 TEST_F(RenderViewTest, OnLoadAlternateHTMLText) { |
| 39 // Test a new navigation. | 41 // Test a new navigation. |
| 40 GURL test_url("http://www.google.com/some_test_url"); | 42 GURL test_url("http://www.google.com/some_test_url"); |
| 41 view_->OnLoadAlternateHTMLText("<html></html>", true, test_url, | 43 view_->OnLoadAlternateHTMLText("<html></html>", true, test_url, |
| 42 std::string()); | 44 std::string()); |
| 43 | 45 |
| 44 // We should have gotten two different types of start messages in the | 46 // We should have gotten two different types of start messages in the |
| 45 // following order. | 47 // following order. |
| 46 ASSERT_EQ((size_t)2, render_thread_.sink().message_count()); | 48 ASSERT_EQ((size_t)2, render_thread_.sink().message_count()); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // Our IME front-end sends many platform-independent messages to the IME backend | 136 // Our IME front-end sends many platform-independent messages to the IME backend |
| 135 // while it composes CJK words. This test sends the minimal messages captured | 137 // while it composes CJK words. This test sends the minimal messages captured |
| 136 // on my local environment directly to the IME backend to verify if the backend | 138 // on my local environment directly to the IME backend to verify if the backend |
| 137 // can compose CJK words without any problems. | 139 // can compose CJK words without any problems. |
| 138 // This test uses an array of command sets because an IME composotion does not | 140 // This test uses an array of command sets because an IME composotion does not |
| 139 // only depends on IME events, but also depends on window events, e.g. moving | 141 // only depends on IME events, but also depends on window events, e.g. moving |
| 140 // the window focus while composing a CJK text. To handle such complicated | 142 // the window focus while composing a CJK text. To handle such complicated |
| 141 // cases, this test should not only call IME-related functions in the | 143 // cases, this test should not only call IME-related functions in the |
| 142 // RenderWidget class, but also call some RenderWidget members, e.g. | 144 // RenderWidget class, but also call some RenderWidget members, e.g. |
| 143 // ExecuteJavaScript(), RenderWidget::OnSetFocus(), etc. | 145 // ExecuteJavaScript(), RenderWidget::OnSetFocus(), etc. |
| 146 // Disabled on Linux: http://crbug.com/27927 |
| 147 #if !defined(OS_LINUX) |
| 144 TEST_F(RenderViewTest, ImeComposition) { | 148 TEST_F(RenderViewTest, ImeComposition) { |
| 145 enum ImeCommand { | 149 enum ImeCommand { |
| 146 IME_INITIALIZE, | 150 IME_INITIALIZE, |
| 147 IME_SETINPUTMODE, | 151 IME_SETINPUTMODE, |
| 148 IME_SETFOCUS, | 152 IME_SETFOCUS, |
| 149 IME_SETCOMPOSITION, | 153 IME_SETCOMPOSITION, |
| 150 }; | 154 }; |
| 151 struct ImeMessage { | 155 struct ImeMessage { |
| 152 ImeCommand command; | 156 ImeCommand command; |
| 153 bool enable; | 157 bool enable; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 if (ime_message->result) { | 255 if (ime_message->result) { |
| 252 // Retrieve the content of this page and compare it with the expected | 256 // Retrieve the content of this page and compare it with the expected |
| 253 // result. | 257 // result. |
| 254 const int kMaxOutputCharacters = 128; | 258 const int kMaxOutputCharacters = 128; |
| 255 std::wstring output = UTF16ToWideHack( | 259 std::wstring output = UTF16ToWideHack( |
| 256 GetMainFrame()->contentAsText(kMaxOutputCharacters)); | 260 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
| 257 EXPECT_EQ(output, ime_message->result); | 261 EXPECT_EQ(output, ime_message->result); |
| 258 } | 262 } |
| 259 } | 263 } |
| 260 } | 264 } |
| 265 #endif |
| 261 | 266 |
| 262 // Test that the RenderView::OnSetTextDirection() function can change the text | 267 // Test that the RenderView::OnSetTextDirection() function can change the text |
| 263 // direction of the selected input element. | 268 // direction of the selected input element. |
| 264 TEST_F(RenderViewTest, OnSetTextDirection) { | 269 TEST_F(RenderViewTest, OnSetTextDirection) { |
| 265 // Load an HTML page consisting of a <textarea> element and a <div> element. | 270 // Load an HTML page consisting of a <textarea> element and a <div> element. |
| 266 // This test changes the text direction of the <textarea> element, and | 271 // This test changes the text direction of the <textarea> element, and |
| 267 // writes the values of its 'dir' attribute and its 'direction' property to | 272 // writes the values of its 'dir' attribute and its 'direction' property to |
| 268 // verify that the text direction is changed. | 273 // verify that the text direction is changed. |
| 269 view_->set_send_content_state_immediately(true); | 274 view_->set_send_content_state_immediately(true); |
| 270 LoadHTML("<html>" | 275 LoadHTML("<html>" |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 WebURLError error; | 917 WebURLError error; |
| 913 error.domain.fromUTF8("test_domain"); | 918 error.domain.fromUTF8("test_domain"); |
| 914 error.reason = net::ERR_ABORTED; | 919 error.reason = net::ERR_ABORTED; |
| 915 error.unreachableURL = GURL("http://foo"); | 920 error.unreachableURL = GURL("http://foo"); |
| 916 WebFrame* web_frame = GetMainFrame(); | 921 WebFrame* web_frame = GetMainFrame(); |
| 917 // A cancellation occurred. | 922 // A cancellation occurred. |
| 918 view_->didFailProvisionalLoad(web_frame, error); | 923 view_->didFailProvisionalLoad(web_frame, error); |
| 919 // Frame should stay in view-source mode. | 924 // Frame should stay in view-source mode. |
| 920 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); | 925 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); |
| 921 } | 926 } |
| OLD | NEW |