diff options
author | Chris Goldthorpe | 2009-10-27 22:57:35 +0000 |
---|---|---|
committer | Chris Goldthorpe | 2009-10-27 22:57:35 +0000 |
commit | 50a60e4ffd8a84f59a64f973f09984335cdeee4c (patch) | |
tree | 3e2a6de3d13e22cd1943929fc73d115ed08caae4 /org.eclipse.ua.tests | |
parent | 93ff1f12a114f412ad69bad6b1ead7c4def380a3 (diff) | |
download | eclipse.platform.ua-50a60e4ffd8a84f59a64f973f09984335cdeee4c.tar.gz eclipse.platform.ua-50a60e4ffd8a84f59a64f973f09984335cdeee4c.tar.xz eclipse.platform.ua-50a60e4ffd8a84f59a64f973f09984335cdeee4c.zip |
Add search tests for meta keywords and meta description
Diffstat (limited to 'org.eclipse.ua.tests')
6 files changed, 108 insertions, 0 deletions
diff --git a/org.eclipse.ua.tests/data/help/search/testMeta.htm b/org.eclipse.ua.tests/data/help/search/testMeta.htm new file mode 100644 index 000000000..b6d59e345 --- /dev/null +++ b/org.eclipse.ua.tests/data/help/search/testMeta.htm @@ -0,0 +1,16 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<head> +<meta http-equiv="Content-Language" content="en-us"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<meta name="description" content="HTML Meta description"> +<meta name="keywords" content="ydhaedrsc"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<title>HTML doc with meta</title> +</head> +<body> + +This is a test for meta tags within an html document + +</body> +</html> diff --git a/org.eclipse.ua.tests/data/help/search/testMeta.xhtml b/org.eclipse.ua.tests/data/help/search/testMeta.xhtml new file mode 100644 index 000000000..7dcca35c4 --- /dev/null +++ b/org.eclipse.ua.tests/data/help/search/testMeta.xhtml @@ -0,0 +1,18 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<meta name="keywords" content="olfrgkjrifjd" /> +<meta name="description" content="XHTML Meta description" /> +<title>XHTML doc with meta</title> +</head> + +<body> + +<p> +XHTML file with meta keyword +</p> + +</body> +</html> diff --git a/org.eclipse.ua.tests/data/help/search/toc.xml b/org.eclipse.ua.tests/data/help/search/toc.xml index 781376c92..fd5f02e7b 100644 --- a/org.eclipse.ua.tests/data/help/search/toc.xml +++ b/org.eclipse.ua.tests/data/help/search/toc.xml @@ -33,5 +33,9 @@ </topic> <topic href="data/help/search/testnlUTF8.htm" label="UTF-8 doc"> </topic> + <topic href="data/help/search/testMeta.htm" label="HTML doc with meta"> + </topic> + <topic href="data/help/search/testMeta.xhtml" label="XHTML doc with meta"> + </topic> </topic> </toc> diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java index 67d721cf3..fb316b3d0 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java @@ -36,5 +36,6 @@ public class AllSearchTests extends TestSuite { addTestSuite(AnalyzerTest.class); addTest(SearchCheatsheet.suite()); addTest(EncodedCharacterSearch.suite()); + addTest(MetaKeywords.suite()); } } diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MetaKeywords.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MetaKeywords.java new file mode 100644 index 000000000..57f191662 --- /dev/null +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MetaKeywords.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.ua.tests.help.search; + + +import java.util.ArrayList; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.help.internal.base.BaseHelpSystem; +import org.eclipse.help.internal.search.ISearchQuery; +import org.eclipse.help.internal.search.SearchHit; +import org.eclipse.help.internal.search.SearchQuery; +import org.eclipse.help.internal.search.SearchResults; + + +public class MetaKeywords extends TestCase { + + /* + * Returns an instance of this Test. + */ + public static Test suite() { + return new TestSuite(MetaKeywords.class); + } + + public void testKeywordInHtml() { + SearchTestUtils.searchAllLocales("ydhaedrsc", new String[] { "/org.eclipse.ua.tests/data/help/search/testMeta.htm" }); + } + + public void testKeywordInXhtml() { + SearchTestUtils.searchAllLocales("olfrgkjrifjd", new String[] { "/org.eclipse.ua.tests/data/help/search/testMeta.xhtml" }); + } + + public void testDescriptionInHtml() { + SearchHit[] hits = getResultDescriptions("ydhaedrsc", "en"); + assertEquals(hits.length, 1); + assertEquals("HTML Meta description", hits[0].getDescription()); + } + + public void testDescriptionInXhtml() { + SearchHit[] hits = getResultDescriptions("olfrgkjrifjd", "en"); + assertEquals(hits.length, 1); + assertEquals("XHTML Meta description", hits[0].getDescription()); + } + + private SearchHit[] getResultDescriptions(String searchWord, String nl) { + ISearchQuery query = new SearchQuery(searchWord, false, new ArrayList(), nl); + SearchResults collector = new SearchResults(null, 500, nl); + BaseHelpSystem.getSearchManager().search(query, collector, new NullProgressMonitor()); + return collector.getSearchHits(); + } + + +} diff --git a/org.eclipse.ua.tests/nl/de/data/help/search/toc.xml b/org.eclipse.ua.tests/nl/de/data/help/search/toc.xml index 86ef3da57..44c06d579 100644 --- a/org.eclipse.ua.tests/nl/de/data/help/search/toc.xml +++ b/org.eclipse.ua.tests/nl/de/data/help/search/toc.xml @@ -29,5 +29,9 @@ </topic> <topic href="data/help/search/test_de.html" label="testde.html"> </topic> + <topic href="data/help/search/testMeta.htm" label="HTML doc with meta"> + </topic> + <topic href="data/help/search/testMeta.xhtml" label="XHTML doc with meta"> + </topic> </topic> </toc> |