Skip to content

Commit

Permalink
Test cleanup (google#3705)
Browse files Browse the repository at this point in the history
* remove references to seamless-poster

* updated feature specs

* cleanup of any

* fixing typos

* more spelling corrections

* updated to poster-dismissed event

* widen tolerance for animation
  • Loading branch information
elalish authored Aug 15, 2022
1 parent 5b12d56 commit 7684f0b
Show file tree
Hide file tree
Showing 46 changed files with 935 additions and 1,140 deletions.
7 changes: 4 additions & 3 deletions packages/model-viewer/src/features/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export declare interface ARInterface {
ar: boolean;
arModes: string;
arScale: string;
arPlacement: string;
iosSrc: string|null;
xrEnvironment: boolean;
readonly canActivateAR: boolean;
Expand Down Expand Up @@ -373,11 +374,11 @@ configuration or device capabilities');
const objectURL = generateUsdz ? await this.prepareUSDZ() : this.iosSrc!;
const modelUrl = new URL(objectURL, self.location.toString());

if(generateUsdz){
if (generateUsdz) {
const location = self.location.toString();
const locationUrl = new URL(location);
const srcUrl = new URL(this.src!, locationUrl);
if(srcUrl.hash){
const srcUrl = new URL(this.src!, locationUrl);
if (srcUrl.hash) {
modelUrl.hash = srcUrl.hash;
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/model-viewer/src/features/scene-graph/material.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class Material extends ThreeDOMElement implements MaterialInterface {

const {
normalTexture: gltfNormalTexture,
occlusionTexture: gltfOcculsionTexture,
occlusionTexture: gltfOcclusionTexture,
emissiveTexture: gltfEmissiveTexture
} = gltfMaterial;

Expand All @@ -143,7 +143,7 @@ export class Material extends ThreeDOMElement implements MaterialInterface {
aoMap,
correlatedMaterials,
gltf,
gltfOcculsionTexture ? gltfOcculsionTexture : null,
gltfOcclusionTexture ? gltfOcclusionTexture : null,
);

this[$emissiveTexture] = new TextureInfo(
Expand Down
2 changes: 1 addition & 1 deletion packages/model-viewer/src/model-viewer-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export default class ModelViewerElementBase extends ReactiveElement {
threshold: 0,
});
} else {
// If there is no intersection obsever, then all models should be visible
// If there is no intersection observer, then all models should be visible
// at all times:
this[$isElementInViewport] = true;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/model-viewer/src/styles/conversions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const degreesToRadians =
};

/**
* Ensures that a given number is expressed in degrees. If the number is alrady
* Ensures that a given number is expressed in degrees. If the number is already
* in degrees, does nothing. If the value is in radians or has no specified
* unit, converts it to degrees. If the value is not in radians or degrees, the
* value is resolved as 0 degrees.
Expand Down
2 changes: 1 addition & 1 deletion packages/model-viewer/src/styles/evaluators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ export class EnvEvaluator extends Evaluator<NumberNode> {


const IS_MULTIPLICATION_RE = /[\*\/]/;
const $evaluator = Symbol('evalutor');
const $evaluator = Symbol('evaluator');

/**
* Evaluator for CSS-like calc() functions. Our implementation of calc()
Expand Down
8 changes: 4 additions & 4 deletions packages/model-viewer/src/styles/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ interface ParseResult<T extends ASTNode> {
* - functions (top-level and nested)
* - calc() arithmetic operators
* - numbers with units
* - hexidecimal-encoded colors in 3, 6 or 8 digit form
* - hexadecimal-encoded colors in 3, 6 or 8 digit form
* - idents
*
* All syntax is intended to match the parsing rules and semantics of the actual
Expand Down Expand Up @@ -134,7 +134,7 @@ export const parseExpressions = (() => {
/**
* Parse a single expression. For the purposes of our supported syntax, an
* expression is the set of semantically meaningful terms that appear before the
* next comma, or between the parens of a function invokation.
* next comma, or between the parens of a function invocation.
*/
const parseExpression = (() => {
const IS_IDENT_RE = /^(\-\-|[a-z\u0240-\uffff])/i;
Expand Down Expand Up @@ -255,7 +255,7 @@ const parseNumber = (() => {


/**
* Parses a hexidecimal-encoded color in 3, 6 or 8 digit form.
* Parses a hexadecimal-encoded color in 3, 6 or 8 digit form.
*/
const parseHex = (() => {
// TODO(cdata): right now we don't actually enforce the number of digits
Expand All @@ -277,7 +277,7 @@ const parseHex = (() => {


/**
* Parses arguments passed to a function invokation (e.g., the expressions
* Parses arguments passed to a function invocation (e.g., the expressions
* within a matched set of parens).
*/
const parseFunctionArguments =
Expand Down
2 changes: 1 addition & 1 deletion packages/model-viewer/src/styles/style-effector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type ScrollObserverCallback = () => void;
* instances of the class, and when the last ScrollObserver "disconnects", that
* event listener is removed. This spares us from thrashing
* the {add,remove}EventListener API (the binding cost of these methods has been
* known to show up in performance anlyses) as well as potential memory leaks.
* known to show up in performance analyses) as well as potential memory leaks.
*/
class ScrollObserver {
private static[$notifyInstances]() {
Expand Down
2 changes: 1 addition & 1 deletion packages/model-viewer/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const templateResult = html`
height: 150px;
}
/* NOTE: This ruleset is our integration surface area with the
/* NOTE: This rule set is our integration surface area with the
* :focus-visible polyfill.
*
* @see https://github.com/WICG/focus-visible/pull/196 */
Expand Down
12 changes: 6 additions & 6 deletions packages/model-viewer/src/test/decorators-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {property} from 'lit/decorators.js';
import {ReactiveElement} from 'lit';
import {property} from 'lit/decorators.js';

import {style} from '../decorators.js';
import {numberNode} from '../styles/parsers.js';
Expand All @@ -28,7 +28,7 @@ const fooIntrinsics = {
keywords: {auto: [null, numberNode(200, '%')]}
};

class StyleableElement extends ReactiveElement {
class StylableElement extends ReactiveElement {
@style({intrinsics: fooIntrinsics, updateHandler: $updateFoo})
@property({type: String})
foo: string = '200cm 1rad';
Expand All @@ -44,13 +44,13 @@ suite('decorators', () => {
suite('@style', () => {
let instance = 0;
let tagName: string;
let element: StyleableElement;
let element: StylableElement;

setup(async () => {
tagName = `styleable-element-${instance++}`;
customElements.define(tagName, class extends StyleableElement {});
tagName = `stylable-element-${instance++}`;
customElements.define(tagName, class extends StylableElement {});

element = document.createElement(tagName) as StyleableElement;
element = document.createElement(tagName) as StylableElement;
document.body.insertBefore(element, document.body.firstChild);

await timePasses();
Expand Down
35 changes: 9 additions & 26 deletions packages/model-viewer/src/test/features/animation-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@
* limitations under the License.
*/

import {AnimationMixin} from '../../features/animation.js';
import ModelViewerElementBase, {$scene} from '../../model-viewer-base.js';
import {$scene} from '../../model-viewer-base.js';
import {ModelViewerElement} from '../../model-viewer.js';
import {timePasses, waitForEvent} from '../../utilities.js';
import {assetPath} from '../helpers.js';
import {BasicSpecTemplate} from '../templates.js';

const expect = chai.expect;
const NON_ANIMATED_GLB_PATH = assetPath('models/Astronaut.glb');
const ANIMATED_GLB_PATH = assetPath('models/RobotExpressive.glb');
const ANIMATED_GLB_DUPLICATE_ANIMATION_NAMES_PATH =
assetPath('models/DuplicateAnimationNames.glb');

const animationIsPlaying = (element: any, animationName = null): boolean => {
const animationIsPlaying = (element: any, animationName?: string): boolean => {
const {currentAnimationAction} = element[$scene];

if (currentAnimationAction != null &&
Expand Down Expand Up @@ -56,32 +55,16 @@ const animationWithIndexIsPlaying = (element: any, animationIndex = 0):
return false;
}

suite('ModelViewerElementBase with AnimationMixin', () => {
let nextId = 0;
let tagName: string;
let ModelViewerElement: any;
let element: any;

setup(() => {
tagName = `model-viewer-animation-${nextId++}`;
ModelViewerElement = class extends AnimationMixin
(ModelViewerElementBase) {
static get is() {
return tagName;
}
};
customElements.define(tagName, ModelViewerElement);
});

BasicSpecTemplate(() => ModelViewerElement, () => tagName);

suite('Animation', () => {
suite('a model with animations', () => {
let element: ModelViewerElement;

setup(async () => {
element = new ModelViewerElement();
element.src = ANIMATED_GLB_PATH;
document.body.insertBefore(element, document.body.firstChild);

await waitForEvent(element, 'load');
await waitForEvent(element, 'poster-dismissed');
});

teardown(() => {
Expand All @@ -108,7 +91,7 @@ suite('ModelViewerElementBase with AnimationMixin', () => {
});

suite('when pause is invoked after a delay', () => {
const delaySeconds = 0.1;
const delaySeconds = 0.2;
setup(async () => {
await timePasses(1000 * delaySeconds);
const animationsPause = waitForEvent(element, 'pause');
Expand All @@ -121,7 +104,7 @@ suite('ModelViewerElementBase with AnimationMixin', () => {
});

test('has a current time close to the delay', () => {
expect(element.currentTime).to.be.closeTo(delaySeconds, 0.05);
expect(element.currentTime).to.be.closeTo(delaySeconds, 0.1);
});

test('changing currentTime triggers render', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/model-viewer/src/test/features/annotation-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const withinRange = (a: Vector2D, start: number, finish: number) => {
expect(a.v).to.be.within(start, finish);
};

suite('ModelViewerElement', () => {
suite('Annotation', () => {
let element: ModelViewerElement;
let scene: ModelScene;

Expand Down
Loading

0 comments on commit 7684f0b

Please sign in to comment.