Project

General

Profile

Download (5.51 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
 * Copyright (C) 2009 EDIT
4
 * European Distributed Institute of Taxonomy
5
 * http://www.e-taxonomy.eu
6
 *
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
10
package eu.etaxonomy.dataportal.selenium.tests.cyprus;
11

    
12
import static org.junit.Assert.*;
13

    
14
import java.net.MalformedURLException;
15
import java.util.List;
16
import java.util.UUID;
17

    
18
import org.junit.After;
19
import org.junit.Before;
20
import org.junit.Test;
21
import org.openqa.selenium.By;
22
import org.openqa.selenium.WebElement;
23

    
24
import eu.etaxonomy.dataportal.DataPortalContext;
25
import eu.etaxonomy.dataportal.elements.BaseElement;
26
import eu.etaxonomy.dataportal.elements.FeatureBlock;
27
import eu.etaxonomy.dataportal.elements.ImgElement;
28
import eu.etaxonomy.dataportal.elements.LinkElement;
29
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
30
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
31
import eu.etaxonomy.dataportal.pages.TaxonProfilePage;
32

    
33
/**
34
 * @author a.kohlbecker
35
 *
36
 */
37

    
38
@DataPortalContexts( { DataPortalContext.cyprus })
39
public class Allium_guttatum_subsp_guttatum_TaxonProfileTest extends CdmDataPortalTestBase{
40

    
41
	static UUID taxonUuid = UUID.fromString("6d04598b-3852-4038-91c9-13c7581b21a6");
42

    
43
	TaxonProfilePage p = null;
44

    
45
	@Before
46
	public void setUp() throws MalformedURLException {
47

    
48
		p = new TaxonProfilePage(driver, getContext(), taxonUuid);
49

    
50
	}
51

    
52
	@After
53
	public void tearDown(){
54
		logger.debug("@After");
55
	}
56

    
57

    
58
	@Test
59
	public void testPage() {
60

    
61
		assertEquals(prepareTitle("Allium guttatum subsp. guttatum"), p.getTitle());
62
		assertNull("Authorship information should be hidden", p.getAuthorInformationText());
63

    
64
		List<LinkElement> primaryTabs = p.getPrimaryTabs();
65
		assertEquals("Expecting 3 tabs", 3, primaryTabs.size());
66
		assertEquals("General", primaryTabs.get(0).getText());
67
		assertEquals("Synonymy", primaryTabs.get(1).getText());
68
		assertEquals("Images", primaryTabs.get(2).getText());
69

    
70
		ImgElement profileImage = p.getProfileImage();
71
		assertNotNull("Expecting profile images to be switched on", profileImage);
72
		assertEquals("http://media.bgbm.org/erez/erez?src=EditWP6/zypern/photos/Allium_guttatum_guttatum_A1.jpg", profileImage.getUrl().toString());
73
		assertEquals(400, profileImage.getDimension().getHeight(), 0.5);
74
		assertEquals(250, profileImage.getDimension().getWidth(), 0.5);
75

    
76
		assertEquals("Content", p.getTableOfContentHeader());
77
		List<LinkElement> links = p.getTableOfContentLinks();
78
		assertNotNull("Expecting a list of TOC links in the profile page.", links);
79
		subtestTableOfContentEntry(0, "Status", "status");
80
		subtestTableOfContentEntry(1, "Endemism", "endemism");
81
		subtestTableOfContentEntry(2, "Red Data Book category", "red_data_book_category");
82
		subtestTableOfContentEntry(3, "Systematics", "systematics");
83
		subtestTableOfContentEntry(4, "Distribution", "distribution");
84

    
85
		FeatureBlock featureBlock = p.getFeatureBlockAt(0, "status", "div", "div");
86
		assertEquals("Status\nIndigenous (IN)", featureBlock.getText());
87

    
88
		featureBlock = p.getFeatureBlockAt(1, "endemism", "div", "div");
89
		assertEquals("Endemism\nnot endemic", featureBlock.getText());
90

    
91
		featureBlock = p.getFeatureBlockAt(2, "red_data_book_category", "div", "div");
92
		assertEquals("Red Data Book category\nData deficient (DD)", featureBlock.getText());
93

    
94
		//FIXME
95
//		featureBlock = p.getFeatureBlockAt(2, "systematics", "div", null);
96
//		assertEquals("Systematics\nTaxonomy and nomenclature follow Mathew (1996).\nMathew B. 1996: A review of Allium section Allium . - Kew.", featureBlock.getText());
97

    
98
		featureBlock = p.getFeatureBlockAt(4, "distribution", "div", "span");
99
		assertEquals("Distribution\nDivision 21\n1. R. D. Meikle, Flora of Cyprus 1. 1977", featureBlock.getText());
100
		assertEquals("Distribution", featureBlock.getHeader());
101
		assertEquals("expecting one footnote key", 1, featureBlock.getFootNoteKeys().size());
102

    
103
		LinkElement footNoteKey_1 = featureBlock.getFootNoteKeys().get(0);
104
		BaseElement footNote_1 = featureBlock.getFootNotes().get(0);
105
		assertTrue("expecting one footnote 0 to be the footnote for key 0",footNote_1.getText().startsWith(footNoteKey_1.getText()));
106
	// FIXME hovering does not jet work
107
//		footNoteKey_1.getElement().hover();
108
//		assertEquals("yellow", footNoteKey_1.getElement().getValueOfCssProperty("background-color"));
109
//		assertEquals("yellow", footNote_1.getElement().getValueOfCssProperty("background-color"));
110

    
111
		assertEquals("1. R. D. Meikle, Flora of Cyprus 1. 1977", footNote_1.getText());
112

    
113
		WebElement distributionMapImage = featureBlock.getElement().findElement(By.className("distribution_map"));
114
		assertEquals("http://edit.br.fgov.be/edit_wp5/v1.1/rest_gen.php?title=a:Indigenous&ad=cyprusdivs:bdcode:a:2&as=z:ffffff,606060,,|y:1874CD,,|a:339966,,0.1,&l=background_gis:y,cyprusdivs:z&ms=500&bbox=32,34,35,36&label=1&img=true&legend=1&mlp=3&mc_s=Georgia,15,blue&mc=&recalculate=false", distributionMapImage.getAttribute("src"));
115

    
116
	}
117

    
118

    
119
	/**
120
	 * @param index
121
	 * @param tocLinkText
122
	 * @param tocLinkFragment
123
	 */
124
	private void subtestTableOfContentEntry(int index, String tocLinkText, String tocLinkFragment) {
125
		assertEquals(tocLinkText, p.getTableOfContentLinks().get(index).getText());
126
		String expectedHref = p.getDrupalPagePath() + "#" + tocLinkFragment;
127
		assertTrue("Expecting the toc link to end with " + expectedHref,  p.getTableOfContentLinks().get(index).getUrl().toString().endsWith(expectedHref));
128
	}
129

    
130
}
(1-1/2)