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

Side by Side Diff: chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc

Issue 1222193006: Remove race in DeclarativeContentApiTest.RulesPersistence test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/declarative_content/persistence/background.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/strings/stringprintf.h" 5 #include "base/strings/stringprintf.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 7 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
8 #include "chrome/browser/extensions/extension_action.h" 8 #include "chrome/browser/extensions/extension_action.h"
9 #include "chrome/browser/extensions/extension_action_manager.h" 9 #include "chrome/browser/extensions/extension_action_manager.h"
10 #include "chrome/browser/extensions/extension_action_test_util.h" 10 #include "chrome/browser/extensions/extension_action_test_util.h"
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 ASSERT_TRUE(extension); 478 ASSERT_TRUE(extension);
479 ASSERT_TRUE(ready.WaitUntilSatisfied()); 479 ASSERT_TRUE(ready.WaitUntilSatisfied());
480 480
481 CreateIncognitoBrowser(); 481 CreateIncognitoBrowser();
482 ASSERT_TRUE(ready_split.WaitUntilSatisfied()); 482 ASSERT_TRUE(ready_split.WaitUntilSatisfied());
483 } 483 }
484 484
485 // Reloads the extension from PRE_RulesPersistence and checks that the rules 485 // Reloads the extension from PRE_RulesPersistence and checks that the rules
486 // continue to work as expected after being persisted and reloaded. 486 // continue to work as expected after being persisted and reloaded.
487 IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, RulesPersistence) { 487 IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, RulesPersistence) {
488 ExtensionTestMessageListener ready("second run ready", false); 488 ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
489 ExtensionTestMessageListener ready_split("second run ready (split)", false); 489 const base::FilePath path = test_data_dir_.
490 ASSERT_TRUE(ready.WaitUntilSatisfied()); 490 AppendASCII("declarative_content").AppendASCII("persistence");
491 const Extension* extension =
492 GetExtensionByPath(registry->enabled_extensions(), path);
491 493
492 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); 494 if (!extension) {
493 const Extension* extension = 495 ExtensionTestMessageListener ready("second run ready", false);
494 GetExtensionByPath(registry->enabled_extensions(), 496 ASSERT_TRUE(ready.WaitUntilSatisfied());
495 test_data_dir_.AppendASCII("declarative_content") 497 extension = GetExtensionByPath(registry->enabled_extensions(), path);
496 .AppendASCII("persistence")); 498 }
497 499
498 // Check non-incognito browser. 500 // Check non-incognito browser.
499 content::WebContents* const tab = 501 content::WebContents* const tab =
500 browser()->tab_strip_model()->GetWebContentsAt(0); 502 browser()->tab_strip_model()->GetWebContentsAt(0);
501 const int tab_id = ExtensionTabUtil::GetTabId(tab); 503 const int tab_id = ExtensionTabUtil::GetTabId(tab);
502 504
503 const ExtensionAction* page_action = 505 const ExtensionAction* page_action =
504 ExtensionActionManager::Get(browser()->profile())-> 506 ExtensionActionManager::Get(browser()->profile())->
505 GetPageAction(*extension); 507 GetPageAction(*extension);
506 ASSERT_TRUE(page_action); 508 ASSERT_TRUE(page_action);
507 EXPECT_FALSE(page_action->GetIsVisible(tab_id)); 509 EXPECT_FALSE(page_action->GetIsVisible(tab_id));
508 510
509 NavigateInRenderer(tab, GURL("http://test_normal/")); 511 NavigateInRenderer(tab, GURL("http://test_normal/"));
510 EXPECT_TRUE(page_action->GetIsVisible(tab_id)); 512 EXPECT_TRUE(page_action->GetIsVisible(tab_id));
511 513
512 NavigateInRenderer(tab, GURL("http://test_split/")); 514 NavigateInRenderer(tab, GURL("http://test_split/"));
513 EXPECT_FALSE(page_action->GetIsVisible(tab_id)); 515 EXPECT_FALSE(page_action->GetIsVisible(tab_id));
514 516
515 // Check incognito browser. 517 // Check incognito browser.
518 ExtensionTestMessageListener ready_split("second run ready (split)", false);
516 Browser* incognito_browser = CreateIncognitoBrowser(); 519 Browser* incognito_browser = CreateIncognitoBrowser();
517 ASSERT_TRUE(ready_split.WaitUntilSatisfied()); 520 ASSERT_TRUE(ready_split.WaitUntilSatisfied());
518 content::WebContents* const incognito_tab = 521 content::WebContents* const incognito_tab =
519 incognito_browser->tab_strip_model()->GetWebContentsAt(0); 522 incognito_browser->tab_strip_model()->GetWebContentsAt(0);
520 const int incognito_tab_id = ExtensionTabUtil::GetTabId(incognito_tab); 523 const int incognito_tab_id = ExtensionTabUtil::GetTabId(incognito_tab);
521 524
522 const ExtensionAction* incognito_page_action = 525 const ExtensionAction* incognito_page_action =
523 ExtensionActionManager::Get(incognito_browser->profile())-> 526 ExtensionActionManager::Get(incognito_browser->profile())->
524 GetPageAction(*extension); 527 GetPageAction(*extension);
525 ASSERT_TRUE(incognito_page_action); 528 ASSERT_TRUE(incognito_page_action);
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 // consistent URL state for all conditions. i.e.: if condition1 evaluates to 808 // consistent URL state for all conditions. i.e.: if condition1 evaluates to
806 // false on url0 and true on url1, and condition2 evaluates to true on url0 and 809 // false on url0 and true on url1, and condition2 evaluates to true on url0 and
807 // false on url1, navigate from url0 to url1 and validate that no action is 810 // false on url1, navigate from url0 to url1 and validate that no action is
808 // triggered. Do the same when navigating back to url0. This kind of test is 811 // triggered. Do the same when navigating back to url0. This kind of test is
809 // unfortunately not feasible with the current implementation and the existing 812 // unfortunately not feasible with the current implementation and the existing
810 // supported conditions and actions. 813 // supported conditions and actions.
811 814
812 } // namespace 815 } // namespace
813 } // namespace extensions 816 } // namespace extensions
814 817
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/declarative_content/persistence/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698