mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
HtmlView UI component added + test
This commit is contained in:
@@ -70,6 +70,7 @@ allTests["LIST-PICKER"] = require("./ui/list-picker/list-picker-tests");
|
||||
allTests["DATE-PICKER"] = require("./ui/date-picker/date-picker-tests");
|
||||
allTests["TIME-PICKER"] = require("./ui/time-picker/time-picker-tests");
|
||||
allTests["WEB-VIEW"] = require("./ui/web-view/web-view-tests");
|
||||
allTests["HTML-VIEW"] = require("./ui/html-view/html-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');
|
||||
|
||||
56
apps/tests/ui/html-view/html-view-tests.ts
Normal file
56
apps/tests/ui/html-view/html-view-tests.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import TKUnit = require("../../TKUnit");
|
||||
import helper = require("../helper");
|
||||
import page = require("ui/page");
|
||||
import types = require("utils/types");
|
||||
|
||||
// <snippet module="ui/html-view" title="HtmlView">
|
||||
// # WebView
|
||||
// Using a HtmlView requires the html-view module.
|
||||
// ``` JavaScript
|
||||
import htmlViewModule = require("ui/html-view");
|
||||
// ```
|
||||
// </snippet>
|
||||
|
||||
// ### Declaring a HtmlView.
|
||||
//```XML
|
||||
// <Page>
|
||||
// <HtmlView html="{{ htmlString }}" />
|
||||
// </Page>
|
||||
//```
|
||||
|
||||
// </snippet>
|
||||
|
||||
var _createHtmlViewFunc = function (): htmlViewModule.HtmlView {
|
||||
// <snippet module="ui/html-view" title="HtmlView">
|
||||
// ### Creating a HtmlView
|
||||
// ``` JavaScript
|
||||
var htmlView = new htmlViewModule.HtmlView();
|
||||
// ```
|
||||
// </snippet>
|
||||
return htmlView;
|
||||
}
|
||||
|
||||
export var testLoadHTMLString = function () {
|
||||
var newPage: page.Page;
|
||||
var htmlView = _createHtmlViewFunc();
|
||||
var pageFactory = function (): page.Page {
|
||||
newPage = new page.Page();
|
||||
newPage.content = htmlView;
|
||||
return newPage;
|
||||
};
|
||||
|
||||
helper.navigate(pageFactory);
|
||||
|
||||
// <snippet module="ui/html-view" title="HtmlView">
|
||||
// ### Using HtmlView
|
||||
// ``` JavaScript
|
||||
htmlView.html = '<span><font color="#ff0000">Test</font></span>';
|
||||
|
||||
helper.goBack();
|
||||
|
||||
if (htmlView.ios) {
|
||||
TKUnit.assert(!types.isNullOrUndefined(htmlView.ios.attributedText), "HTML string not loaded properly. Actual: " + htmlView.ios.attributedText);
|
||||
} else if (htmlView.android) {
|
||||
TKUnit.assert(htmlView.android.getText(), "HTML string not loaded properly. Actual: " + htmlView.android.getText());
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@
|
||||
<TabViewItem.view>
|
||||
<StackLayout>
|
||||
|
||||
<HtmlView html="<span><font color='#ff0000'>Test</font></span>" />
|
||||
|
||||
<WebView src="<html><body><span style='color:red'>Test</span></body></html>" />
|
||||
|
||||
<!--<ToolBar>
|
||||
|
||||
Reference in New Issue
Block a user