mirror of
https://github.com/NASAWorldWind/WebWorldWind.git
synced 2025-12-08 19:46:18 +00:00
* Modified texture modulation to always modulate to white - Corrected wrong logger message call in TextRenderer - Corrected missing semicolon in TextRenderer - Corrected missing color string in state key of TextAttributes * Modified documentation to reflect how color is now applied to the text * Removed parameters from TextRenderer functions that are now unneeded - Removed getMaxLineHeight function. - Updated call of textRenderer.wrap in Annotation. * Returned getMaxLineHeight function for documentation purposes * Modified TextRenderer unit test to fit new function parameters * First draft of DrawContext.renderText - Counterpart to WWA's RenderContext.renderText. * First propagation of textAttributes to Text through DrawContext - Bug: ScreenText and Annotations examples show their text in incorrect colors. * Modified Annotation to use new DrawContext.renderText - Annotations example updated to explicitly remove outline from the annotation's text. - Temporary outline settings for dc.textRenderer are now unneeded and are removed as well. * Corrected Annotation's configuration of fragment program color * Modified Placemark to use new DrawContext.renderText function * Corrected wrong assignation of outlineColor * Updated DrawContext.renderText and TextRenderer documentation * Disabled Annotation's text outline by default in its constructor - Removed superfluous change in TextRenderer documentation - Removed text outline disable in Annotations example * Changed default TextAttributes to a more appropriate name * Refactored AnnotationAttributes' default text fields for readability
78 lines
2.9 KiB
JavaScript
78 lines
2.9 KiB
JavaScript
define([
|
|
'src/util/Font',
|
|
'src/render/TextRenderer',
|
|
'src/geom/Vec2'
|
|
], function (Font,
|
|
TextRenderer,
|
|
Vec2) {
|
|
"use strict";
|
|
describe("TextRenderer tests", function () {
|
|
|
|
// Mocking TextRenderer.textSize() to avoid 2D context requirement.
|
|
TextRenderer.prototype.textSize = function (text, font, outline) {
|
|
return new Vec2(text.length * 7, 16);
|
|
};
|
|
|
|
// Mocking draw context to avoid WebGL requirements.
|
|
var DrawContext = function () {
|
|
this.currentGlContext = "fake GL context";
|
|
this.pixelScale = 1;
|
|
this.textRenderer = new TextRenderer(this);
|
|
};
|
|
|
|
var testText = "Lorem ipsum dolor sit amet, consectetur "
|
|
+ "adipiscing elit, sed do eiusmod tempor incididunt ut";
|
|
|
|
var mockDrawContext = new DrawContext;
|
|
|
|
it("Should throw an exception on missing constructor draw context", function () {
|
|
expect(function () {
|
|
var mockTextRenderer = new TextRenderer(null);
|
|
}).toThrow();
|
|
});
|
|
|
|
it("Should return null due to empty string input on RenderText", function () {
|
|
var mockTextRenderer = new TextRenderer(mockDrawContext);
|
|
expect(mockTextRenderer.renderText("")).toBeNull();
|
|
});
|
|
|
|
it("Should throw an exception on missing text input", function () {
|
|
expect(function () {
|
|
var mockTextRenderer = new TextRenderer(mockDrawContext);
|
|
mockTextRenderer.wrap(null, 20, 100);
|
|
}).toThrow();
|
|
});
|
|
|
|
it("Should output '...' due to wrap height being less than textSize height", function () {
|
|
var mockTextRenderer = new TextRenderer(mockDrawContext);
|
|
var wrappedText = mockTextRenderer.wrap(testText, 92, 15);
|
|
expect(wrappedText).toEqual("...");
|
|
});
|
|
|
|
it("Should output 'Lorem ipsum...' due to wrap width being less than textSize width", function () {
|
|
var mockTextRenderer = new TextRenderer(mockDrawContext);
|
|
var wrappedText = mockTextRenderer.wrap(testText, 90, 16);
|
|
expect(wrappedText).toEqual("Lorem ipsum...");
|
|
});
|
|
|
|
it("Should output every word on testText in different lines", function () {
|
|
var mockTextRenderer = new TextRenderer(mockDrawContext);
|
|
// Wrap line width less than textSize texture width
|
|
var wrappedLines = mockTextRenderer.wrapLine(testText, 0);
|
|
expect(wrappedLines).toEqual("Lorem\n" +
|
|
"ipsum\n" +
|
|
"dolor\n" +
|
|
"sit\n" +
|
|
"amet,\n" +
|
|
"consectetur\n" +
|
|
"adipiscing\n" +
|
|
"elit,\n" +
|
|
"sed\n" +
|
|
"do\n" +
|
|
"eiusmod\n" +
|
|
"tempor\n" +
|
|
"incididunt\n" +
|
|
"ut");
|
|
});
|
|
})
|
|
}); |