Skip to content

Commit

Permalink
test: add test for setting global font (#9436)
Browse files Browse the repository at this point in the history
Fixes #9409
# Conflicts:
#	flow-tests/test-themes/src/main/java/com/vaadin/flow/uitest/ui/theme/ThemeView.java
  • Loading branch information
caalador committed Feb 16, 2021
1 parent 090a603 commit 4f140f7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
Binary file not shown.
6 changes: 6 additions & 0 deletions flow-tests/test-themes/frontend/theme/app-theme/global.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
@font-face {
font-family: "Ostrich";
src: url("theme/app-theme/font/ostrich-sans-regular.ttf") format("TrueType");
}

body {
background-image: url('theme/app-theme/img/bg.jpg');
font-family: "Ostrich";
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
@Theme(themeFolder = "app-theme")
public class ThemeView extends Div {

public static final String TEST_TEXT_ID = "test-text";

public ThemeView() {
add(new Span("This is the theme test view"));
final Span textSpan = new Span("This is the theme test view");
textSpan.setId(TEST_TEXT_ID);
add(textSpan);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import com.vaadin.flow.testutil.ChromeBrowserTest;

Expand All @@ -40,9 +41,12 @@ public void applicationTheme_GlobalCss_isUsed() {
// No exception for bg-image should exist
checkLogsForErrors();

final WebElement body = findElement(By.tagName("body"));
Assert.assertEquals(
"url(\"" + getRootURL() + "/theme/app-theme/img/bg.jpg\")",
findElement(By.tagName("body")).getCssValue("background-image"));
body.getCssValue("background-image"));

Assert.assertEquals("Ostrich", body.getCssValue("font-family"));

getDriver().get(getRootURL() + "/theme/app-theme/img/bg.jpg");
Assert.assertFalse("app-theme background file should be served",
Expand Down

0 comments on commit 4f140f7

Please sign in to comment.