Adding Search Hint text color; since this is not accessible from the standard style/theming xml files.

Added Tests so that it will verify the search bar color is changing.
This commit is contained in:
Nathanael Anderson
2015-05-19 00:45:20 -05:00
parent 20fb94ebe3
commit b259cde7fd
9 changed files with 135 additions and 1 deletions

View File

@@ -70,6 +70,7 @@ allTests["TIME-PICKER"] = require("./ui/time-picker/time-picker-tests");
allTests["WEB-VIEW"] = require("./ui/web-view/web-view-tests");
allTests["WEAK-EVENTS"] = require("./weak-event-listener-tests");
allTests["REPEATER"] = require("./ui/repeater/repeater-tests");
allTests["SEARCH-BAR"] = require('./ui/search-bar/search-bar-tests');
if (!isRunningOnEmulator()) {
allTests["LOCATION"] = require("./location-tests");

View File

@@ -0,0 +1,22 @@
import colorModule = require("color");
import searchBarModule = require("ui/search-bar");
function getTextView(bar: android.widget.SearchView): android.widget.TextView {
if (bar) {
var id = bar.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
if (id) {
return <android.widget.TextView> bar.findViewById(id);
}
}
return undefined;
}
export function getNativeHintColor(searchBar: searchBarModule.SearchBar): colorModule.Color {
var textView = getTextView(searchBar.android);
if (textView) {
return new colorModule.Color(textView.getHintTextColors().getDefaultColor());
}
return undefined;
}

View File

@@ -0,0 +1,5 @@
//@private
import searchBarModule = require("ui/search-bar");
import colorModule = require("color");
export declare function getNativeHintColor(textView: searchBarModule.SearchBar): colorModule.Color;

View File

@@ -0,0 +1,7 @@
import colorModule = require("color");
import searchBarModule = require("ui/search-bar");
export function getNativeHintColor(searchBar: searchBarModule.SearchBar): colorModule.Color {
// TODO: This test needs to be created
return undefined;
}

View File

@@ -1,4 +1,9 @@
import observable = require("data/observable");
import TKUnit = require("../../TKUnit");
import helper = require("../helper");
import viewModule = require("ui/core/view");
import searchBarTestsNative = require("./search-bar-tests-native");
import colorModule = require("color");
import observable = require("data/observable");
// <snippet module="ui/search-bar" title="search-bar">
// # SearchBar
// Using the SearchBar requires the "ui/search-bar" module.
@@ -15,6 +20,44 @@ import searchBarModule = require("ui/search-bar");
//```
// </snippet>
var _createSearchBarFunc = function (): searchBarModule.SearchBar {
// <snippet module="ui/search-bar" title="SearchBar">
// ### Creating a SearchBar
// ``` JavaScript
var searchBar = new searchBarModule.SearchBar();
// ```
// </snippet>
searchBar.text = "searchBar";
return searchBar;
};
export var testSearchBarHintColorAndroid = 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;
var actualValue;
searchBar.textFieldHintColor = new colorModule.Color("blue");
expectedValue = "#ff0000ff"; // blue
actualValue = searchBarTestsNative.getNativeHintColor(searchBar).hex;
TKUnit.assert(actualValue === expectedValue, "Actual: " + actualValue + "; Expected: " + expectedValue);
searchBar.textFieldHintColor = new colorModule.Color("red");
expectedValue = "#ffff0000"; // Red
actualValue = searchBarTestsNative.getNativeHintColor(searchBar).hex;
TKUnit.assert(actualValue === expectedValue, "Actual: " + actualValue + "; Expected: " + expectedValue);
});
};
export function test_DummyTestForSnippetOnly() {
// <snippet module="ui/search-bar" title="search-bar">
// ### Searching