Commit fff68b41 authored by Rohit Rao's avatar Rohit Rao Committed by Commit Bot

[ios] Reworks +setUpForTestCase to be called once per XCTestCase.

The previous implementation was inadvertently calling +setUpForTestCase
once per test module, rather than once per XCTestCase.

BUG=922813,977161

Change-Id: I49d0f5bc442c4bd793b85f932149699d24f5e665
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1692527Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Rohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#675999}
parent c970b6c8
......@@ -22,6 +22,15 @@
GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(BaseEarlGreyTestCaseAppInterface)
#endif // defined(CHROME_EARL_GREY_2)
namespace {
// If true, +setUpForTestCase will be called from -setUp. This flag is used to
// ensure that +setUpForTestCase is called exactly once per unique XCTestCase
// and is reset in +tearDown.
bool g_needs_set_up_for_test_case = true;
} // namespace
@implementation BaseEarlGreyTestCase
+ (void)setUpForTestCase {
......@@ -46,11 +55,16 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(BaseEarlGreyTestCaseAppInterface)
[self failIfSetUpIsOverridden];
#endif
static dispatch_once_t setupToken;
dispatch_once(&setupToken, ^{
if (g_needs_set_up_for_test_case) {
g_needs_set_up_for_test_case = false;
[CoverageUtils configureCoverageReportPath];
[[self class] setUpForTestCase];
});
}
}
+ (void)tearDown {
g_needs_set_up_for_test_case = true;
[super tearDown];
}
// Handles system alerts if any are present, closing them to unblock the UI.
......
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