Commit ef54bb1e authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Mitigate timing issues with Safe Browsing test.

Bug: 931826, 916806
Change-Id: Id48042e7f7c567e3174d9afa6f9fc09b2b85ae31
Reviewed-on: https://chromium-review.googlesource.com/c/1470717Reviewed-by: default avatarPeter Lee <pkl@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Peter Lee <pkl@chromium.org>
Auto-Submit: Kurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632002}
parent ae4ff4ee
...@@ -57,6 +57,7 @@ source_set("unit_tests") { ...@@ -57,6 +57,7 @@ source_set("unit_tests") {
deps = [ deps = [
":safe_mode", ":safe_mode",
"//base", "//base",
"//base/test:test_support",
"//ios/chrome/browser/crash_report", "//ios/chrome/browser/crash_report",
"//ios/chrome/test/base", "//ios/chrome/test/base",
"//ios/chrome/test/ocmock", "//ios/chrome/test/ocmock",
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
// found in the LICENSE file. // found in the LICENSE file.
#import "ios/chrome/browser/ui/safe_mode/safe_mode_view_controller.h" #import "ios/chrome/browser/ui/safe_mode/safe_mode_view_controller.h"
#import "base/test/ios/wait_util.h"
#import "ios/chrome/browser/crash_report/breakpad_helper.h" #import "ios/chrome/browser/crash_report/breakpad_helper.h"
#import "ios/chrome/browser/crash_report/main_thread_freeze_detector.h"
#import "ios/chrome/test/base/scoped_block_swizzler.h" #import "ios/chrome/test/base/scoped_block_swizzler.h"
#import "ios/chrome/test/ocmock/OCMockObject+BreakpadControllerTesting.h" #import "ios/chrome/test/ocmock/OCMockObject+BreakpadControllerTesting.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -61,6 +63,20 @@ TEST_F(SafeModeViewControllerTest, HasSuggestions) { ...@@ -61,6 +63,20 @@ TEST_F(SafeModeViewControllerTest, HasSuggestions) {
EXPECT_FALSE([SafeModeViewController hasSuggestions]); EXPECT_FALSE([SafeModeViewController hasSuggestions]);
breakpad_helper::SetUploadingEnabled(false); breakpad_helper::SetUploadingEnabled(false);
EXPECT_TRUE(base::test::ios::WaitUntilConditionOrTimeout(
// Calling SetUploadingEnabled() for the first time kicks off several
// asynchronous calls that ultimately result in MainThreadFreezeDetector's
// |-canUploadBreakpadCrashReports| being flipped to YES. Subsequent
// calls will perform synchronously after |canUploadBreakpadCrashReports|
// is YES. The OCMock verification calls below expect these selectors to
// be called synchronously, so wait until |canUploadBreakpadCrashReports|
// is YES before continuing the test.
// TODO(crbug.com/931826): Remove timing assumptions for the OCMock
// verification calls below.
base::test::ios::kWaitForUIElementTimeout, ^bool {
return [MainThreadFreezeDetector sharedInstance]
.canUploadBreakpadCrashReports;
}));
EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_); EXPECT_OCMOCK_VERIFY(mock_breakpad_controller_);
EXPECT_FALSE([SafeModeViewController hasSuggestions]); EXPECT_FALSE([SafeModeViewController hasSuggestions]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment