mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
font-size CSS support for search-bar + test
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import colorModule = require("color");
|
||||
import searchBarModule = require("ui/search-bar");
|
||||
import utils = require("utils/utils");
|
||||
|
||||
function getTextView(bar: android.widget.SearchView): android.widget.TextView {
|
||||
if (bar) {
|
||||
@@ -20,3 +21,12 @@ export function getNativeHintColor(searchBar: searchBarModule.SearchBar): colorM
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getNativeFontSize(searchBar: searchBarModule.SearchBar): number {
|
||||
var textView = getTextView(searchBar.android);
|
||||
|
||||
if (textView) {
|
||||
return textView.getTextSize() / utils.layout.getDisplayDensity();
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -3,3 +3,4 @@ import searchBarModule = require("ui/search-bar");
|
||||
import colorModule = require("color");
|
||||
|
||||
export declare function getNativeHintColor(textView: searchBarModule.SearchBar): colorModule.Color;
|
||||
export declare function getNativeFontSize(searchBar: searchBarModule.SearchBar): number;
|
||||
@@ -5,3 +5,13 @@ export function getNativeHintColor(searchBar: searchBarModule.SearchBar): colorM
|
||||
// TODO: This test needs to be created
|
||||
return undefined;
|
||||
}
|
||||
export function getNativeFontSize(searchBar: searchBarModule.SearchBar): number {
|
||||
var bar = <UISearchBar>searchBar.ios;
|
||||
var sf = <UITextField>bar.valueForKey("_searchField");
|
||||
if (sf) {
|
||||
return sf.font.pointSize;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,27 @@ export var testSearchBarHintColorAndroid = function () {
|
||||
});
|
||||
};
|
||||
|
||||
export var testSearchBarFontSize = function () {
|
||||
helper.buildUIAndRunTest(_createSearchBarFunc(), function (views: Array<viewModule.View>) {
|
||||
var searchBar = <searchBarModule.SearchBar>views[0];
|
||||
|
||||
// TODO: create IOS test once IOS support is working
|
||||
if (!searchBar.android) {
|
||||
return;
|
||||
}
|
||||
|
||||
searchBar.text = "";
|
||||
searchBar.hint = "hint color test";
|
||||
|
||||
var expectedValue = 30;
|
||||
var actualValue;
|
||||
|
||||
searchBar.style.fontSize = expectedValue;
|
||||
actualValue = searchBarTestsNative.getNativeFontSize(searchBar);
|
||||
TKUnit.assert(actualValue === expectedValue, "Actual: " + actualValue + "; Expected: " + expectedValue);
|
||||
});
|
||||
};
|
||||
|
||||
export function test_DummyTestForSnippetOnly() {
|
||||
// <snippet module="ui/search-bar" title="search-bar">
|
||||
// ### Searching
|
||||
|
||||
Reference in New Issue
Block a user