| 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 | 5 |
| 6 #include <algorithm> | 6 #include <algorithm> |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 287 |
| 288 DISALLOW_COPY_AND_ASSIGN(NavEntryCommittedObserver); | 288 DISALLOW_COPY_AND_ASSIGN(NavEntryCommittedObserver); |
| 289 }; | 289 }; |
| 290 | 290 |
| 291 namespace { | 291 namespace { |
| 292 | 292 |
| 293 class TestRenderViewContextMenu : public RenderViewContextMenu { | 293 class TestRenderViewContextMenu : public RenderViewContextMenu { |
| 294 public: | 294 public: |
| 295 static TestRenderViewContextMenu* CreateContextMenu( | 295 static TestRenderViewContextMenu* CreateContextMenu( |
| 296 WebContents* web_contents) { | 296 WebContents* web_contents) { |
| 297 ContextMenuParams params; | 297 content::ContextMenuParams params; |
| 298 params.media_type = WebKit::WebContextMenuData::MediaTypeNone; | 298 params.media_type = WebKit::WebContextMenuData::MediaTypeNone; |
| 299 params.x = 0; | 299 params.x = 0; |
| 300 params.y = 0; | 300 params.y = 0; |
| 301 params.is_image_blocked = false; | 301 params.is_image_blocked = false; |
| 302 params.media_flags = 0; | 302 params.media_flags = 0; |
| 303 params.spellcheck_enabled = false; | 303 params.spellcheck_enabled = false; |
| 304 params.is_editable = false; | 304 params.is_editable = false; |
| 305 params.page_url = web_contents->GetController().GetActiveEntry()->GetURL(); | 305 params.page_url = web_contents->GetController().GetActiveEntry()->GetURL(); |
| 306 #if defined(OS_MACOSX) | 306 #if defined(OS_MACOSX) |
| 307 params.writing_direction_default = 0; | 307 params.writing_direction_default = 0; |
| 308 params.writing_direction_left_to_right = 0; | 308 params.writing_direction_left_to_right = 0; |
| 309 params.writing_direction_right_to_left = 0; | 309 params.writing_direction_right_to_left = 0; |
| 310 #endif // OS_MACOSX | 310 #endif // OS_MACOSX |
| 311 params.edit_flags = WebContextMenuData::CanTranslate; | 311 params.edit_flags = WebContextMenuData::CanTranslate; |
| 312 return new TestRenderViewContextMenu(web_contents, params); | 312 return new TestRenderViewContextMenu(web_contents, params); |
| 313 } | 313 } |
| 314 | 314 |
| 315 bool IsItemPresent(int id) { | 315 bool IsItemPresent(int id) { |
| 316 return menu_model_.GetIndexOfCommandId(id) != -1; | 316 return menu_model_.GetIndexOfCommandId(id) != -1; |
| 317 } | 317 } |
| 318 | 318 |
| 319 virtual void PlatformInit() { } | 319 virtual void PlatformInit() { } |
| 320 virtual bool GetAcceleratorForCommandId( | 320 virtual bool GetAcceleratorForCommandId( |
| 321 int command_id, | 321 int command_id, |
| 322 ui::Accelerator* accelerator) { return false; } | 322 ui::Accelerator* accelerator) { return false; } |
| 323 | 323 |
| 324 private: | 324 private: |
| 325 TestRenderViewContextMenu(WebContents* web_contents, | 325 TestRenderViewContextMenu(WebContents* web_contents, |
| 326 const ContextMenuParams& params) | 326 const content::ContextMenuParams& params) |
| 327 : RenderViewContextMenu(web_contents, params) { | 327 : RenderViewContextMenu(web_contents, params) { |
| 328 } | 328 } |
| 329 | 329 |
| 330 DISALLOW_COPY_AND_ASSIGN(TestRenderViewContextMenu); | 330 DISALLOW_COPY_AND_ASSIGN(TestRenderViewContextMenu); |
| 331 }; | 331 }; |
| 332 | 332 |
| 333 } // namespace | 333 } // namespace |
| 334 | 334 |
| 335 TEST_F(TranslateManagerTest, NormalTranslate) { | 335 TEST_F(TranslateManagerTest, NormalTranslate) { |
| 336 // Simulate navigating to a page. | 336 // Simulate navigating to a page. |
| (...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1425 NULL); | 1425 NULL); |
| 1426 // Now simulate the URL fetch. | 1426 // Now simulate the URL fetch. |
| 1427 SimulateTranslateScriptURLFetch(true); | 1427 SimulateTranslateScriptURLFetch(true); |
| 1428 // Now the message should have been sent. | 1428 // Now the message should have been sent. |
| 1429 int page_id = 0; | 1429 int page_id = 0; |
| 1430 std::string original_lang, target_lang; | 1430 std::string original_lang, target_lang; |
| 1431 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 1431 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 1432 EXPECT_EQ("es", original_lang); | 1432 EXPECT_EQ("es", original_lang); |
| 1433 EXPECT_EQ("en", target_lang); | 1433 EXPECT_EQ("en", target_lang); |
| 1434 } | 1434 } |
| OLD | NEW |