Skip to content

Commit

Permalink
[Fiber] Add more tests for scheduling (#8183)
Browse files Browse the repository at this point in the history
* Add more tests for scheduling

* Remove ambiguous terms
  • Loading branch information
gaearon authored Nov 2, 2016
1 parent e5d85fb commit 99be378
Show file tree
Hide file tree
Showing 9 changed files with 516 additions and 5 deletions.
24 changes: 21 additions & 3 deletions scripts/fiber/tests-passing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -795,9 +795,27 @@ src/renderers/shared/fiber/__tests__/ReactIncrementalReflection-test.js
* finds no node before insertion and correct node before deletion

src/renderers/shared/fiber/__tests__/ReactIncrementalScheduling-test.js
* schedules multiple roots
* works on deferred roots in the order they were scheduled
* works on roots with animation priority before deferred work
* schedules and flushes hi-pri work
* schedules and flushes hi-pri work for many roots
* flushes all scheduled hi-pri work
* flushes all scheduled hi-pri work for many roots
* schedules and flushes lo-pri work
* schedules and flushes lo-pri work for many roots
* flushes scheduled lo-pri work fitting within deadline
* flushes scheduled lo-pri work fitting within deadline for many roots
* schedules more lo-pri work if it runs out of time
* schedules more lo-pri work if it runs out of time with many roots
* FIXME: flushes late hi-pri work in a lo-pri callback if it wins
* FIXME: flushes late hi-pri work in a lo-pri callback if it wins with many roots
* FIXME: ignores late hi-pri work in a hi-pri callback if it wins
* FIXME: ignores late hi-pri work in a hi-pri callback if it wins with many roots
* FIXME: ignores all work in a lo-pri callback if it wins
* FIXME: ignores all work in a lo-pri callback if it wins with many roots
* flushes root with late lo-pri work in a hi-pri callback if it wins
* flushes all roots with hi-pri work in a hi-pri callback if it wins
* splits lo-pri work on multiple roots
* works on lo-pri roots in the order they were scheduled
* handles interleaved lo-pri and hi-pri work

src/renderers/shared/fiber/__tests__/ReactIncrementalSideEffects-test.js
* can update child nodes of a host instance
Expand Down
20 changes: 20 additions & 0 deletions src/renderers/noop/ReactNoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,22 @@ var NoopRenderer = ReactFiberReconciler({
},

scheduleAnimationCallback(callback) {
if (scheduledAnimationCallback) {
throw new Error(
'Scheduling an animation callback twice is excessive. ' +
'Instead, keep track of whether the callback has already been scheduled.'
);
}
scheduledAnimationCallback = callback;
},

scheduleDeferredCallback(callback) {
if (scheduledDeferredCallback) {
throw new Error(
'Scheduling deferred callback twice is excessive. ' +
'Instead, keep track of whether the callback has already been scheduled.'
);
}
scheduledDeferredCallback = callback;
},

Expand All @@ -160,6 +172,14 @@ var ReactNoop = {
}
},

hasScheduledDeferredCallback() {
return Boolean(scheduledDeferredCallback);
},

hasScheduledAnimationCallback() {
return Boolean(scheduledAnimationCallback);
},

// Shortcut for testing a single root
render(element : ReactElement<any>, callback: ?Function) {
ReactNoop.renderToRootWithID(element, DEFAULT_ROOT_ID, callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var ReactCoroutine;

describe('ReactCoroutine', () => {
beforeEach(() => {
jest.resetModuleRegistry();
React = require('React');
ReactNoop = require('ReactNoop');
ReactCoroutine = require('ReactCoroutine');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var ReactNoop;

describe('ReactIncremental', () => {
beforeEach(() => {
jest.resetModuleRegistry();
React = require('React');
ReactNoop = require('ReactNoop');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var ReactNoop;

describe('ReactIncrementalReflection', () => {
beforeEach(() => {
jest.resetModuleRegistry();
React = require('React');
ReactNoop = require('ReactNoop');
});
Expand Down
Loading

0 comments on commit 99be378

Please sign in to comment.