Add failing test for FontCacheTask::add_web_font

This test tries to add a web font to the `FontCacheTask`. The added web font
corresponds to the following CSS font definition:

```
@font-face {
  font-family: "test family";
  src: local(test font face);
}
```

This test fails, since `FontCacheTask` tries to get the value for the key
"test font face" from `self.web_families`, but previously initialized
a value for the key "test family".
This commit is contained in:
Adrian Heine 2016-01-04 10:36:14 +01:00
parent 5ad9207a99
commit 3f61d63e72
4 changed files with 32 additions and 0 deletions

View file

@ -650,6 +650,8 @@ name = "gfx_tests"
version = "0.0.1"
dependencies = [
"gfx 0.0.1",
"ipc-channel 0.1.0 (git+https://github.com/servo/ipc-channel)",
"style 0.0.1",
]
[[package]]

View file

@ -10,3 +10,9 @@ doctest = false
[dependencies.gfx]
path = "../../../components/gfx"
[dependencies.ipc-channel]
git = "https://github.com/servo/ipc-channel"
[dependencies.style]
path = "../../../components/style"

View file

@ -0,0 +1,21 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use gfx::font_cache_task::FontCacheTask;
use ipc_channel::ipc;
use style::computed_values::font_family::FontFamily;
use style::font_face::Source;
#[test]
fn test_local_web_font() {
let (inp_chan, _) = ipc::channel().unwrap();
let (out_chan, out_receiver) = ipc::channel().unwrap();
let font_cache_task = FontCacheTask::new(inp_chan);
let family_name = FontFamily::FamilyName(From::from("test family"));
let variant_name = FontFamily::FamilyName(From::from("test font face"));
font_cache_task.add_web_font(family_name, Source::Local(variant_name), out_chan);
assert_eq!(out_receiver.recv().unwrap(), ());
}

View file

@ -3,5 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
extern crate gfx;
extern crate ipc_channel;
extern crate style;
#[cfg(test)] mod font_cache_task;
#[cfg(test)] mod text_util;