OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 ASSERT_TRUE(manager_.GetItemById(id1) == NULL); | 341 ASSERT_TRUE(manager_.GetItemById(id1) == NULL); |
342 ASSERT_TRUE(manager_.GetItemById(item2->id()) != NULL); | 342 ASSERT_TRUE(manager_.GetItemById(item2->id()) != NULL); |
343 } | 343 } |
344 | 344 |
345 // A mock message service for tests of ExtensionMenuManager::ExecuteCommand. | 345 // A mock message service for tests of ExtensionMenuManager::ExecuteCommand. |
346 class MockExtensionEventRouter : public ExtensionEventRouter { | 346 class MockExtensionEventRouter : public ExtensionEventRouter { |
347 public: | 347 public: |
348 explicit MockExtensionEventRouter(Profile* profile) : | 348 explicit MockExtensionEventRouter(Profile* profile) : |
349 ExtensionEventRouter(profile) {} | 349 ExtensionEventRouter(profile) {} |
350 | 350 |
351 MOCK_METHOD6(DispatchEventImpl, void(const std::string& extension_id, | 351 MOCK_METHOD7(DispatchEventImpl, void(const std::string& extension_id, |
352 const std::string& event_name, | 352 const std::string& event_name, |
353 const std::string& event_args, | 353 const std::string& event_args, |
354 Profile* source_profile, | 354 Profile* source_profile, |
355 const std::string& cross_incognito_args, | 355 const std::string& cross_incognito_args, |
356 const GURL& event_url)); | 356 const GURL& event_url, |
| 357 bool was_pending)); |
357 | 358 |
358 private: | 359 private: |
359 DISALLOW_COPY_AND_ASSIGN(MockExtensionEventRouter); | 360 DISALLOW_COPY_AND_ASSIGN(MockExtensionEventRouter); |
360 }; | 361 }; |
361 | 362 |
362 // A mock profile for tests of ExtensionMenuManager::ExecuteCommand. | 363 // A mock profile for tests of ExtensionMenuManager::ExecuteCommand. |
363 class MockTestingProfile : public TestingProfile { | 364 class MockTestingProfile : public TestingProfile { |
364 public: | 365 public: |
365 MockTestingProfile() {} | 366 MockTestingProfile() {} |
366 MOCK_METHOD0(GetExtensionEventRouter, ExtensionEventRouter*()); | 367 MOCK_METHOD0(GetExtensionEventRouter, ExtensionEventRouter*()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 // Use the magic of googlemock to save a parameter to our mock's | 445 // Use the magic of googlemock to save a parameter to our mock's |
445 // DispatchEventToExtension method into event_args. | 446 // DispatchEventToExtension method into event_args. |
446 std::string event_args; | 447 std::string event_args; |
447 std::string expected_event_name = "contextMenus"; | 448 std::string expected_event_name = "contextMenus"; |
448 EXPECT_CALL(*mock_event_router.get(), | 449 EXPECT_CALL(*mock_event_router.get(), |
449 DispatchEventImpl(item->extension_id(), | 450 DispatchEventImpl(item->extension_id(), |
450 expected_event_name, | 451 expected_event_name, |
451 _, | 452 _, |
452 &profile, | 453 &profile, |
453 "", | 454 "", |
454 GURL())) | 455 GURL(), |
| 456 false)) |
455 .Times(1) | 457 .Times(1) |
456 .WillOnce(SaveArg<2>(&event_args)); | 458 .WillOnce(SaveArg<2>(&event_args)); |
457 | 459 |
458 manager_.ExecuteCommand(&profile, NULL /* tab_contents */, params, id); | 460 manager_.ExecuteCommand(&profile, NULL /* tab_contents */, params, id); |
459 | 461 |
460 // Parse the json event_args, which should turn into a 2-element list where | 462 // Parse the json event_args, which should turn into a 2-element list where |
461 // the first element is a dictionary we want to inspect for the correct | 463 // the first element is a dictionary we want to inspect for the correct |
462 // values. | 464 // values. |
463 scoped_ptr<Value> result(base::JSONReader::Read(event_args, true)); | 465 scoped_ptr<Value> result(base::JSONReader::Read(event_args, true)); |
464 Value* value = result.get(); | 466 Value* value = result.get(); |
(...skipping 18 matching lines...) Expand all Loading... |
483 ASSERT_EQ(params.page_url.spec(), tmp); | 485 ASSERT_EQ(params.page_url.spec(), tmp); |
484 | 486 |
485 string16 tmp16; | 487 string16 tmp16; |
486 ASSERT_TRUE(info->GetString("selectionText", &tmp16)); | 488 ASSERT_TRUE(info->GetString("selectionText", &tmp16)); |
487 ASSERT_EQ(params.selection_text, tmp16); | 489 ASSERT_EQ(params.selection_text, tmp16); |
488 | 490 |
489 bool bool_tmp = true; | 491 bool bool_tmp = true; |
490 ASSERT_TRUE(info->GetBoolean("editable", &bool_tmp)); | 492 ASSERT_TRUE(info->GetBoolean("editable", &bool_tmp)); |
491 ASSERT_EQ(params.is_editable, bool_tmp); | 493 ASSERT_EQ(params.is_editable, bool_tmp); |
492 } | 494 } |
OLD | NEW |