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

Unified Diff: chrome/browser/upgrade_detector_impl_unittest.cc

Issue 2591913002: Fix use-after-free issues in UpgradeDetectorImplTest. (Closed)
Patch Set: Improve comments Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/upgrade_detector_impl_unittest.cc
diff --git a/chrome/browser/upgrade_detector_impl_unittest.cc b/chrome/browser/upgrade_detector_impl_unittest.cc
index 9646b894f42ca2664c997cd41d4348adf2f2e201..4a0b400b57fbd3f0a41c9c2b7f8e9fe97431074a 100644
--- a/chrome/browser/upgrade_detector_impl_unittest.cc
+++ b/chrome/browser/upgrade_detector_impl_unittest.cc
@@ -7,11 +7,13 @@
#include <vector>
#include "base/macros.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
class TestUpgradeDetectorImpl : public UpgradeDetectorImpl {
@@ -88,6 +90,10 @@ TEST(UpgradeDetectorImplTest, VariationsChanges) {
EXPECT_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
notifications_listener.notifications_received().front());
EXPECT_EQ(0, detector.trigger_critical_update_call_count());
+
+ // Execute tasks sent to FILE thread by |detector| referencing it
+ // while it's still in scope.
+ content::RunAllPendingInMessageLoop(content::BrowserThread::FILE);
}
TEST(UpgradeDetectorImplTest, VariationsCriticalChanges) {
@@ -109,4 +115,8 @@ TEST(UpgradeDetectorImplTest, VariationsCriticalChanges) {
EXPECT_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
notifications_listener.notifications_received().front());
EXPECT_EQ(1, detector.trigger_critical_update_call_count());
+
+ // Execute tasks sent to FILE thread by |detector| referencing it
+ // while it's still in scope.
+ content::RunAllPendingInMessageLoop(content::BrowserThread::FILE);
}
« 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