Permalink
Browse files

Drop checking the height in the FontWatchRunner. Also remove webfont.…

…Size as it is no longer needed.
  • Loading branch information...
1 parent 29309ab commit 38e2a613f2047b3058c19132bffd41bd82392fff @bramstein bramstein committed Mar 6, 2013
@@ -10,17 +10,17 @@ describe('FontRuler', function () {
it('should prevent a long test string from word wrapping', function () {
var fontRulerA = new FontRuler(domHelper, 'abc'),
- fontRulerB = new FontRuler(domHelper, 'Hello World, this should wrap!');
+ fontRulerB = new FontRuler(domHelper, 'abc HelloWorld,thisshouldwrap!!!!');
fontRulerA.insert();
fontRulerB.insert();
fontRulerA.setFont('sans-serif');
fontRulerB.setFont('sans-serif');
- var sizeA = fontRulerA.getSize(),
- sizeB = fontRulerB.getSize();
+ var widthA = fontRulerA.getWidth(),
+ widthB = fontRulerB.getWidth();
- expect(sizeA.height).toEqual(sizeB.height);
+ expect(widthA).not.toEqual(widthB);
});
});
@@ -2,7 +2,6 @@ describe('FontWatchRunner', function () {
var FontWatchRunner = webfont.FontWatchRunner,
BrowserInfo = webfont.BrowserInfo,
UserAgentParser = webfont.UserAgentParser,
- Size = webfont.Size,
DomHelper = webfont.DomHelper,
FontRuler = webfont.FontRuler;
@@ -20,40 +19,40 @@ describe('FontWatchRunner', function () {
describe('Fake browser', function () {
var fontFamily = 'My Family',
fontDescription = 'n4',
- TARGET_SIZE = new Size(3, 3),
- FALLBACK_SIZE_A = new Size(1, 1),
- FALLBACK_SIZE_B = new Size(2, 2),
- LAST_RESORT_SIZE = new Size(4, 4),
+ TARGET_SIZE = 3,
+ FALLBACK_SIZE_A = 1,
+ FALLBACK_SIZE_B = 2,
+ LAST_RESORT_SIZE = 4,
browserInfo = new BrowserInfo(true, false, false),
fallbackBugBrowserInfo = new BrowserInfo(true, true, false),
- setupSizes = [],
- actualSizes = [],
+ setupWidths = [],
+ actualWidths = [],
timesToGetTimeBeforeTimeout = 10;
beforeEach(function () {
jasmine.Clock.useMock();
- setupSizes = [FALLBACK_SIZE_A, FALLBACK_SIZE_B, LAST_RESORT_SIZE];
+ setupWidths = [FALLBACK_SIZE_A, FALLBACK_SIZE_B, LAST_RESORT_SIZE];
- actualSizes = [];
+ actualWidths = [];
var setupFinished = false,
- fakeGetSizeCount = 0;
+ fakeGetWidthCount = 0;
- spyOn(FontRuler.prototype, 'getSize').andCallFake(function () {
+ spyOn(FontRuler.prototype, 'getWidth').andCallFake(function () {
var result = null;
if (setupFinished) {
// If you are getting an exception here your tests does not specify enough
// size data to run properly.
- if (fakeGetSizeCount >= actualSizes.length) {
+ if (fakeGetWidthCount >= actualWidths.length) {
throw 'Invalid test data';
}
- result = actualSizes[fakeGetSizeCount];
- fakeGetSizeCount += 1;
+ result = actualWidths[fakeGetWidthCount];
+ fakeGetWidthCount += 1;
} else {
- result = setupSizes[Math.min(fakeGetSizeCount, setupSizes.length - 1)];
- fakeGetSizeCount += 1;
+ result = setupWidths[Math.min(fakeGetWidthCount, setupWidths.length - 1)];
+ fakeGetWidthCount += 1;
}
return result;
});
@@ -73,14 +72,14 @@ describe('FontWatchRunner', function () {
spyOn(FontWatchRunner.prototype, 'start').andCallFake(function () {
setupFinished = true;
- fakeGetSizeCount = 0;
+ fakeGetWidthCount = 0;
originalStart.apply(this);
});
});
it('should call active if fonts are already loaded', function () {
- actualSizes = [
+ actualWidths = [
TARGET_SIZE, TARGET_SIZE
];
@@ -94,7 +93,7 @@ describe('FontWatchRunner', function () {
});
it('should wait for font load and call active', function () {
- actualSizes = [
+ actualWidths = [
FALLBACK_SIZE_A, FALLBACK_SIZE_B,
FALLBACK_SIZE_A, FALLBACK_SIZE_B,
FALLBACK_SIZE_A, FALLBACK_SIZE_B,
@@ -113,7 +112,7 @@ describe('FontWatchRunner', function () {
it('should wait for font inactive and call inactive', function () {
timesToGetTimeBeforeTimeout = 5;
- actualSizes = [
+ actualWidths = [
FALLBACK_SIZE_A, FALLBACK_SIZE_B,
FALLBACK_SIZE_A, FALLBACK_SIZE_B,
FALLBACK_SIZE_A, FALLBACK_SIZE_B,
@@ -132,7 +131,7 @@ describe('FontWatchRunner', function () {
describe('WebKit fallback bug', function () {
it('should ignore fallback size and call active', function () {
- actualSizes = [
+ actualWidths = [
LAST_RESORT_SIZE, LAST_RESORT_SIZE,
TARGET_SIZE, TARGET_SIZE
];
@@ -147,7 +146,7 @@ describe('FontWatchRunner', function () {
});
it('should consider last resort font as having identical metrics and call active', function () {
- actualSizes = [
+ actualWidths = [
LAST_RESORT_SIZE, LAST_RESORT_SIZE,
LAST_RESORT_SIZE, LAST_RESORT_SIZE
];
@@ -164,7 +163,7 @@ describe('FontWatchRunner', function () {
});
it('should fail to load font and call inactive', function () {
- actualSizes = [
+ actualWidths = [
LAST_RESORT_SIZE, LAST_RESORT_SIZE,
LAST_RESORT_SIZE, LAST_RESORT_SIZE,
FALLBACK_SIZE_A, FALLBACK_SIZE_B
@@ -182,7 +181,7 @@ describe('FontWatchRunner', function () {
});
it('should call inactive when we are loading a metric incompatible font', function () {
- actualSizes = [
+ actualWidths = [
LAST_RESORT_SIZE, LAST_RESORT_SIZE,
LAST_RESORT_SIZE, LAST_RESORT_SIZE
];
@@ -200,7 +199,7 @@ describe('FontWatchRunner', function () {
});
it('should call active when we are loading a metric compatible font', function () {
- actualSizes = [
+ actualWidths = [
LAST_RESORT_SIZE, LAST_RESORT_SIZE,
LAST_RESORT_SIZE, LAST_RESORT_SIZE
];
@@ -218,24 +217,6 @@ describe('FontWatchRunner', function () {
});
});
- describe('webkit metrics bug', function () {
- it('should correctly call active even though the height is different', function () {
- actualSizes = [
- FALLBACK_SIZE_A, FALLBACK_SIZE_B,
- new Size(1, 2), new Size(2, 3), // Same as FALLBACK_SIZE_A and FALLBACK_SIZE_B except that the height is different.
- TARGET_SIZE, TARGET_SIZE
- ];
-
- var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
- domHelper, fontFamily, fontDescription, new BrowserInfo(true, false, true));
-
- fontWatchRunner.start();
-
- jasmine.Clock.tick(2 * 25);
- expect(activeCallback).toHaveBeenCalledWith('My Family', 'n4');
- });
- });
-
describe('test string', function () {
var fontWatchRunner = null;
@@ -244,7 +225,7 @@ describe('FontWatchRunner', function () {
});
it('should be the default', function () {
- actualSizes = [
+ actualWidths = [
TARGET_SIZE, TARGET_SIZE
];
fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
@@ -257,7 +238,7 @@ describe('FontWatchRunner', function () {
});
it('should be a custom string', function () {
- actualSizes = [
+ actualWidths = [
TARGET_SIZE, TARGET_SIZE
];
@@ -302,14 +283,14 @@ describe('FontWatchRunner', function () {
var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
domHelper, 'SourceSansA', '', userAgent.getBrowserInfo(), 500),
ruler = new FontRuler(domHelper, 'abcdef'),
- activeSize = null,
- originalSize = null,
+ activeWidth = null,
+ originalWidth = null,
finalCheck = false;
runs(function () {
ruler.insert();
ruler.setFont('monospace');
- originalSize = ruler.getSize();
+ originalWidth = ruler.getWidth();
ruler.setFont("'SourceSansA', monospace");
fontWatchRunner.start();
});
@@ -320,8 +301,8 @@ describe('FontWatchRunner', function () {
runs(function () {
expect(activeCallback).toHaveBeenCalledWith('SourceSansA', '');
- activeSize = ruler.getSize();
- expect(activeSize).not.toEqual(originalSize);
+ activeWidth = ruler.getWidth();
+ expect(activeWidth).not.toEqual(originalWidth);
window.setTimeout(function () {
finalCheck = true;
@@ -333,8 +314,8 @@ describe('FontWatchRunner', function () {
});
runs(function () {
- expect(ruler.getSize()).not.toEqual(originalSize);
- expect(ruler.getSize()).toEqual(activeSize);
+ expect(ruler.getWidth()).not.toEqual(originalWidth);
+ expect(ruler.getWidth()).toEqual(activeWidth);
});
});
@@ -359,14 +340,14 @@ describe('FontWatchRunner', function () {
var fontWatchRunner = new FontWatchRunner(activeCallback, inactiveCallback,
domHelper, 'SourceSansB', '', userAgent.getBrowserInfo(), 500),
ruler = new FontRuler(domHelper, 'abcdef'),
- activeSize = null,
- originalSize = null,
+ activeWidth = null,
+ originalWidth = null,
finalCheck = false;
runs(function () {
ruler.insert();
ruler.setFont('monospace');
- originalSize = ruler.getSize();
+ originalWidth = ruler.getWidth();
ruler.setFont("'SourceSansB', monospace");
fontWatchRunner.start();
var link = document.createElement('link');
@@ -383,8 +364,8 @@ describe('FontWatchRunner', function () {
runs(function () {
expect(activeCallback).toHaveBeenCalledWith('SourceSansB', '');
- activeSize = ruler.getSize();
- expect(activeSize).not.toEqual(originalSize);
+ activeWidth = ruler.getWidth();
+ expect(activeWidth).not.toEqual(originalWidth);
window.setTimeout(function () {
finalCheck = true;
@@ -396,8 +377,8 @@ describe('FontWatchRunner', function () {
});
runs(function () {
- expect(ruler.getSize()).not.toEqual(originalSize);
- expect(ruler.getSize()).toEqual(activeSize);
+ expect(ruler.getWidth()).not.toEqual(originalWidth);
+ expect(ruler.getWidth()).toEqual(activeWidth);
});
});
});
View
@@ -7,14 +7,13 @@ goog.addDependency("../../src/core/cssclassname.js", ["webfont.CssClassName"], [
goog.addDependency("../../src/core/cssfontfamilyname.js", ["webfont.CssFontFamilyName"], []);
goog.addDependency("../../src/core/domhelper.js", ["webfont.DomHelper"], []);
goog.addDependency("../../src/core/eventdispatcher.js", ["webfont.EventDispatcher"], ["webfont.CssClassName"]);
-goog.addDependency("../../src/core/font.js", ["webfont.WebFont"], ["webfont.DomHelper","webfont.EventDispatcher","webfont.FontWatcher","webfont.Size"]);
+goog.addDependency("../../src/core/font.js", ["webfont.WebFont"], ["webfont.DomHelper","webfont.EventDispatcher","webfont.FontWatcher"]);
goog.addDependency("../../src/core/fontmoduleloader.js", ["webfont.FontModuleLoader"], []);
-goog.addDependency("../../src/core/fontruler.js", ["webfont.FontRuler"], ["webfont.CssFontFamilyName","webfont.FontVariationDescription","webfont.Size"]);
+goog.addDependency("../../src/core/fontruler.js", ["webfont.FontRuler"], ["webfont.CssFontFamilyName","webfont.FontVariationDescription"]);
goog.addDependency("../../src/core/fontvariationdescription.js", ["webfont.FontVariationDescription"], []);
goog.addDependency("../../src/core/fontwatcher.js", ["webfont.FontWatcher"], ["webfont.FontWatchRunner"]);
goog.addDependency("../../src/core/fontwatchrunner.js", ["webfont.FontWatchRunner"], ["webfont.FontRuler"]);
goog.addDependency("../../src/core/initialize.js", ["webfont"], ["webfont.UserAgentParser","webfont.FontModuleLoader","webfont.WebFont"]);
-goog.addDependency("../../src/core/size.js", ["webfont.Size"], []);
goog.addDependency("../../src/core/useragent.js", ["webfont.UserAgent"], []);
goog.addDependency("../../src/core/useragentparser.js", ["webfont.UserAgentParser"], ["webfont.BrowserInfo","webfont.UserAgent"]);
goog.addDependency("../../src/custom/customcss.js", ["webfont.CustomCss"], []);
Oops, something went wrong.

0 comments on commit 38e2a61

Please sign in to comment.