Call out to delegate for control users in experiments (#923)

This commit is contained in:
Adlai Holler
2018-05-16 08:33:28 -07:00
committed by GitHub
parent 0830f6cf23
commit 73cdc1b4e4
3 changed files with 9 additions and 9 deletions

View File

@@ -50,6 +50,7 @@
- Adds an experiment to call ASNetworkImageNode callbacks off main. [Garrett Moon](https://github.com/garrettmoon)
- Prevent UITextView from updating contentOffset while deallocating [Michael Schneider](https://github.com/maicki)
- [ASCollectionNode/ASTableNode] Fix a crash occurs while remeasuring cell nodes. [Huy Nguyen](https://github.com/nguyenhuy) [#917](https://github.com/TextureGroup/Texture/pull/917)
- Fix an issue where ASConfigurationDelegate would not call out for "control" users. If set, it now receives events whenever an experimental feature decision point occurs, whether it's enabled or not. [Adlai Holler](https://github.com/Adlai-Holler)
## 2.6
- [Xcode 9] Updated to require Xcode 9 (to fix warnings) [Garrett Moon](https://github.com/garrettmoon)

View File

@@ -63,10 +63,11 @@
NSAssert(__builtin_popcount(requested) == 1, @"Cannot activate multiple features at once with this method.");
// If they're disabled, ignore them.
// We need to call out, whether it's enabled or not.
// A/B testing requires even "control" users to be activated.
ASExperimentalFeatures enabled = requested & _config.experimentalFeatures;
ASExperimentalFeatures prevTriggered = atomic_fetch_or(&_activatedExperiments, enabled);
ASExperimentalFeatures newlyTriggered = enabled & ~prevTriggered;
ASExperimentalFeatures prevTriggered = atomic_fetch_or(&_activatedExperiments, requested);
ASExperimentalFeatures newlyTriggered = requested & ~prevTriggered;
// Notify delegate if needed.
if (newlyTriggered != 0) {

View File

@@ -33,14 +33,11 @@
[ASConfigurationManager test_resetWithConfiguration:config];
// Set an expectation for a callback, and assert we only get one.
XCTestExpectation *e = [self expectationWithDescription:@"Callback 1 done."];
XCTestExpectation *e = [self expectationWithDescription:@"Callbacks done."];
e.expectedFulfillmentCount = 2;
e.assertForOverFulfill = YES;
onActivate = ^(ASConfigurationTests *self, ASExperimentalFeatures feature) {
XCTAssertEqual(feature, ASExperimentalGraphicsContexts);
[e fulfill];
// Next time it's a fail.
self->onActivate = ^(ASConfigurationTests *self, ASExperimentalFeatures feature) {
XCTFail(@"Too many callbacks.");
};
};
// Now activate the graphics experiment and expect it works.
@@ -48,6 +45,7 @@
// We should get a callback here
// Now activate text node and expect it fails.
XCTAssertFalse(ASActivateExperimentalFeature(ASExperimentalTextNode));
// But we should get another callback.
[self waitForExpectationsWithTimeout:3 handler:nil];
}