Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Side by Side Diff: chrome/browser/extensions/extension_action_runner_browsertest.cc

Issue 2257113002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/extensions/extension_action_runner.h" 5 #include "chrome/browser/extensions/extension_action_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 // injected. 466 // injected.
467 ExtensionActionRunner* runner = 467 ExtensionActionRunner* runner =
468 ExtensionActionRunner::GetForWebContents(web_contents); 468 ExtensionActionRunner::GetForWebContents(web_contents);
469 ASSERT_TRUE(runner); 469 ASSERT_TRUE(runner);
470 EXPECT_TRUE(runner->WantsToRun(extension)); 470 EXPECT_TRUE(runner->WantsToRun(extension));
471 EXPECT_EQ("undefined", GetValue(web_contents)); 471 EXPECT_EQ("undefined", GetValue(web_contents));
472 472
473 // Wire up the runner to automatically accept the bubble to prompt for page 473 // Wire up the runner to automatically accept the bubble to prompt for page
474 // refresh. 474 // refresh.
475 runner->set_default_bubble_close_action_for_testing( 475 runner->set_default_bubble_close_action_for_testing(
476 base::WrapUnique(new ToolbarActionsBarBubbleDelegate::CloseAction( 476 base::MakeUnique<ToolbarActionsBarBubbleDelegate::CloseAction>(
477 ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE))); 477 ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE));
478 478
479 content::NavigationEntry* entry = 479 content::NavigationEntry* entry =
480 web_contents->GetController().GetLastCommittedEntry(); 480 web_contents->GetController().GetLastCommittedEntry();
481 ASSERT_TRUE(entry); 481 ASSERT_TRUE(entry);
482 const int first_nav_id = entry->GetUniqueID(); 482 const int first_nav_id = entry->GetUniqueID();
483 483
484 // Run the extension action, which should cause a page refresh (since we 484 // Run the extension action, which should cause a page refresh (since we
485 // automatically accepted the bubble prompting us), and the extension should 485 // automatically accepted the bubble prompting us), and the extension should
486 // have injected at document start. 486 // have injected at document start.
487 runner->RunAction(extension, true); 487 runner->RunAction(extension, true);
(...skipping 14 matching lines...) Expand all
502 web_contents->GetController().Reload(true); 502 web_contents->GetController().Reload(true);
503 EXPECT_TRUE(content::WaitForLoadStop(web_contents)); 503 EXPECT_TRUE(content::WaitForLoadStop(web_contents));
504 504
505 // The extension should again want to run. Automatically dismiss the bubble 505 // The extension should again want to run. Automatically dismiss the bubble
506 // that pops up prompting for page refresh. 506 // that pops up prompting for page refresh.
507 EXPECT_TRUE(runner->WantsToRun(extension)); 507 EXPECT_TRUE(runner->WantsToRun(extension));
508 EXPECT_EQ("undefined", GetValue(web_contents)); 508 EXPECT_EQ("undefined", GetValue(web_contents));
509 const int next_nav_id = 509 const int next_nav_id =
510 web_contents->GetController().GetLastCommittedEntry()->GetUniqueID(); 510 web_contents->GetController().GetLastCommittedEntry()->GetUniqueID();
511 runner->set_default_bubble_close_action_for_testing( 511 runner->set_default_bubble_close_action_for_testing(
512 base::WrapUnique(new ToolbarActionsBarBubbleDelegate::CloseAction( 512 base::MakeUnique<ToolbarActionsBarBubbleDelegate::CloseAction>(
513 ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_USER_ACTION))); 513 ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_USER_ACTION));
514 514
515 // Try running the extension. Nothing should happen, because the user 515 // Try running the extension. Nothing should happen, because the user
516 // didn't agree to refresh the page. The extension should still want to run. 516 // didn't agree to refresh the page. The extension should still want to run.
517 runner->RunAction(extension, true); 517 runner->RunAction(extension, true);
518 base::RunLoop().RunUntilIdle(); 518 base::RunLoop().RunUntilIdle();
519 EXPECT_TRUE(content::WaitForLoadStop(web_contents)); 519 EXPECT_TRUE(content::WaitForLoadStop(web_contents));
520 EXPECT_EQ("undefined", GetValue(web_contents)); 520 EXPECT_EQ("undefined", GetValue(web_contents));
521 EXPECT_EQ( 521 EXPECT_EQ(
522 next_nav_id, 522 next_nav_id,
523 web_contents->GetController().GetLastCommittedEntry()->GetUniqueID()); 523 web_contents->GetController().GetLastCommittedEntry()->GetUniqueID());
524 524
525 // Repeat with a dismissal from bubble deactivation - same story. 525 // Repeat with a dismissal from bubble deactivation - same story.
526 runner->set_default_bubble_close_action_for_testing( 526 runner->set_default_bubble_close_action_for_testing(
527 base::WrapUnique(new ToolbarActionsBarBubbleDelegate::CloseAction( 527 base::MakeUnique<ToolbarActionsBarBubbleDelegate::CloseAction>(
528 ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_DEACTIVATION))); 528 ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_DEACTIVATION));
529 runner->RunAction(extension, true); 529 runner->RunAction(extension, true);
530 base::RunLoop().RunUntilIdle(); 530 base::RunLoop().RunUntilIdle();
531 EXPECT_TRUE(content::WaitForLoadStop(web_contents)); 531 EXPECT_TRUE(content::WaitForLoadStop(web_contents));
532 EXPECT_EQ("undefined", GetValue(web_contents)); 532 EXPECT_EQ("undefined", GetValue(web_contents));
533 EXPECT_EQ( 533 EXPECT_EQ(
534 next_nav_id, 534 next_nav_id,
535 web_contents->GetController().GetLastCommittedEntry()->GetUniqueID()); 535 web_contents->GetController().GetLastCommittedEntry()->GetUniqueID());
536 } 536 }
537 537
538 // A version of the test with the flag off, in order to test that everything 538 // A version of the test with the flag off, in order to test that everything
(...skipping 23 matching lines...) Expand all
562 562
563 ASSERT_TRUE(embedded_test_server()->Start()); 563 ASSERT_TRUE(embedded_test_server()->Start());
564 ui_test_utils::NavigateToURL( 564 ui_test_utils::NavigateToURL(
565 browser(), embedded_test_server()->GetURL("/extensions/test_file.html")); 565 browser(), embedded_test_server()->GetURL("/extensions/test_file.html"));
566 566
567 for (size_t i = 0u; i < arraysize(testers); ++i) 567 for (size_t i = 0u; i < arraysize(testers); ++i)
568 EXPECT_TRUE(testers[i].Verify()) << kExtensionNames[i]; 568 EXPECT_TRUE(testers[i].Verify()) << kExtensionNames[i];
569 } 569 }
570 570
571 } // namespace extensions 571 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_action_runner.cc ('k') | chrome/browser/extensions/extension_action_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698