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

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

Issue 8774027: Fix ExtensionCrashRecoveryTest.TwoExtensionsIgnoreFirst. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ^w Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 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 "base/process_util.h" 5 #include "base/process_util.h"
6 #include "chrome/browser/browser_process.h" 6 #include "chrome/browser/browser_process.h"
7 #include "chrome/browser/extensions/extension_browsertest.h" 7 #include "chrome/browser/extensions/extension_browsertest.h"
8 #include "chrome/browser/extensions/extension_host.h" 8 #include "chrome/browser/extensions/extension_host.h"
9 #include "chrome/browser/extensions/extension_process_manager.h" 9 #include "chrome/browser/extensions/extension_process_manager.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 Balloon* balloon = GetNotificationDelegate(index); 44 Balloon* balloon = GetNotificationDelegate(index);
45 ASSERT_TRUE(balloon); 45 ASSERT_TRUE(balloon);
46 balloon->OnClick(); 46 balloon->OnClick();
47 WaitForExtensionLoad(); 47 WaitForExtensionLoad();
48 } 48 }
49 49
50 void CancelNotification(size_t index) { 50 void CancelNotification(size_t index) {
51 Balloon* balloon = GetNotificationDelegate(index); 51 Balloon* balloon = GetNotificationDelegate(index);
52 NotificationUIManager* manager = 52 NotificationUIManager* manager =
53 g_browser_process->notification_ui_manager(); 53 g_browser_process->notification_ui_manager();
54 manager->CancelById(balloon->notification().notification_id()); 54 ASSERT_TRUE(manager->CancelById(balloon->notification().notification_id()));
55 } 55 }
56 56
57 size_t CountBalloons() { 57 size_t CountBalloons() {
58 NotificationUIManager* manager = 58 NotificationUIManager* manager =
59 g_browser_process->notification_ui_manager(); 59 g_browser_process->notification_ui_manager();
60 BalloonCollection::Balloons balloons = 60 BalloonCollection::Balloons balloons =
61 manager->balloon_collection()->GetActiveBalloons(); 61 manager->balloon_collection()->GetActiveBalloons();
62 return balloons.size(); 62 return balloons.size();
63 } 63 }
64 64
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 MAYBE_TwoExtensionsShutdownWhileCrashed) { 348 MAYBE_TwoExtensionsShutdownWhileCrashed) {
349 const size_t size_before = GetExtensionService()->extensions()->size(); 349 const size_t size_before = GetExtensionService()->extensions()->size();
350 LoadTestExtension(); 350 LoadTestExtension();
351 CrashExtension(size_before); 351 CrashExtension(size_before);
352 ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); 352 ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
353 LoadSecondExtension(); 353 LoadSecondExtension();
354 CrashExtension(size_before); 354 CrashExtension(size_before);
355 ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); 355 ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
356 } 356 }
357 357
358 // Flaky on mac&&linux due to http://crbug.com/89078.
359 #if defined(OS_LINUX) || defined(OS_MACOSX)
360 #define MAYBE_TwoExtensionsIgnoreFirst FLAKY_TwoExtensionsIgnoreFirst
361 #else
362 #define MAYBE_TwoExtensionsIgnoreFirst TwoExtensionsIgnoreFirst
363 #endif // defined(OS_LINUX) || defined(OS_MACOSX)
364 IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, 358 IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
365 MAYBE_TwoExtensionsIgnoreFirst) { 359 TwoExtensionsIgnoreFirst) {
366 const size_t size_before = GetExtensionService()->extensions()->size(); 360 const size_t size_before = GetExtensionService()->extensions()->size();
367 LoadTestExtension(); 361 LoadTestExtension();
368 LoadSecondExtension(); 362 LoadSecondExtension();
369 CrashExtension(size_before); 363 CrashExtension(size_before);
370 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); 364 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
371 CrashExtension(size_before); 365 CrashExtension(size_before);
372 ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); 366 ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
373 367
368 // Accept notification 1 before canceling notification 0.
369 // Otherwise, on Linux and Windows, there is a race here, in which
370 // canceled notifications do not immediately go away.
371 AcceptNotification(1);
374 CancelNotification(0); 372 CancelNotification(0);
375 // Cancelling the balloon at 0 will close the balloon, and the balloon in
376 // index 1 will move into index 0.
377 AcceptNotification(0);
378 373
379 SCOPED_TRACE("balloons done"); 374 SCOPED_TRACE("balloons done");
380 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); 375 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
376 EXPECT_EQ(second_extension_id_,
377 GetExtensionService()->extensions()->at(size_before)->id());
381 CheckExtensionConsistency(size_before); 378 CheckExtensionConsistency(size_before);
382 } 379 }
383 380
384 IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, 381 IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
385 TwoExtensionsReloadIndependently) { 382 TwoExtensionsReloadIndependently) {
386 const size_t size_before = GetExtensionService()->extensions()->size(); 383 const size_t size_before = GetExtensionService()->extensions()->size();
387 LoadTestExtension(); 384 LoadTestExtension();
388 LoadSecondExtension(); 385 LoadSecondExtension();
389 CrashExtension(size_before); 386 CrashExtension(size_before);
390 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); 387 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 content::NOTIFICATION_LOAD_STOP, 484 content::NOTIFICATION_LOAD_STOP,
488 content::Source<NavigationController>( 485 content::Source<NavigationController>(
489 &browser()->GetSelectedTabContentsWrapper()->controller())); 486 &browser()->GetSelectedTabContentsWrapper()->controller()));
490 browser()->Reload(CURRENT_TAB); 487 browser()->Reload(CURRENT_TAB);
491 observer.Wait(); 488 observer.Wait();
492 } 489 }
493 // Extension should now be loaded. 490 // Extension should now be loaded.
494 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); 491 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
495 ASSERT_EQ(0U, CountBalloons()); 492 ASSERT_EQ(0U, CountBalloons());
496 } 493 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698