1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.test.ui.po

File ChangesPane.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
11
7
1
132
58
7
0.64
1.57
7
1

Classes

Class Line # Actions
ChangesPane 37 11 0% 7 0
1.0100%
 

Contributing tests

This file is covered by 4 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.test.ui.po;
21   
22    import java.util.ArrayList;
23    import java.util.List;
24   
25    import org.openqa.selenium.By;
26    import org.openqa.selenium.WebElement;
27    import org.openqa.selenium.support.FindBy;
28    import org.xwiki.test.ui.po.diff.DocumentDiffSummary;
29    import org.xwiki.test.ui.po.diff.EntityDiff;
30   
31    /**
32    * Displays the differences between two versions of a document.
33    *
34    * @version $Id: d95caa6074757b140d63f7325211bb62a31a56a0 $
35    * @since 4.2M1
36    */
 
37    public class ChangesPane extends BaseElement
38    {
39    /**
40    * The element that wraps all the changes.
41    */
42    @FindBy(id = "changescontent")
43    private WebElement container;
44   
45    /**
46    * The summary of the older version
47    */
48    @FindBy(id = "changes-info-box-from")
49    private WebElement fromVersionSummary;
50   
51    /**
52    * The summary of the newer version.
53    */
54    @FindBy(id = "changes-info-box-to")
55    private WebElement toVersionSummary;
56   
57    /**
58    * The comment for the to version.
59    */
60    @FindBy(id = "changes-info-comment")
61    private WebElement changeComment;
62   
63    @FindBy(className = "diff-summary")
64    private WebElement diffSummary;
65   
66    /**
67    * @return the summary of the from version
68    */
 
69  1 toggle public String getFromVersionSummary()
70    {
71  1 return fromVersionSummary.getText();
72    }
73   
74    /**
75    * @return the summary of the to version
76    */
 
77  1 toggle public String getToVersionSummary()
78    {
79  1 return toVersionSummary.getText();
80    }
81   
82    /**
83    * @return the comment of the to version
84    */
 
85  1 toggle public String getChangeComment()
86    {
87  1 return changeComment.getText();
88    }
89   
90    /**
91    * @return {@code true} if the "No changes" message is displayed and there are no diffs displayed, {@code false}
92    * otherwise
93    */
 
94  1 toggle public boolean hasNoChanges()
95    {
96  1 return getDriver().findElementsWithoutWaiting(container,
97    By.xpath("div[@class = 'infomessage' and . = 'No changes']")).size() > 0
98    && getChangedEntities().isEmpty();
99    }
100   
101    /**
102    * @return the summary for the displayed changes
103    */
 
104  2 toggle public DocumentDiffSummary getDiffSummary()
105    {
106  2 return new DocumentDiffSummary(this.diffSummary);
107    }
108   
109    /**
110    * @return the names (labels) for the entities that have been modified (have modified properties)
111    */
 
112  3 toggle public List<String> getChangedEntities()
113    {
114  3 List<WebElement> elements = getDriver().findElementsWithoutWaiting(By.xpath("//dl[@class = 'diff-group']/dt"));
115  3 List<String> labels = new ArrayList<>();
116  3 for (WebElement element : elements) {
117  7 labels.add(element.getText().trim());
118    }
119  3 return labels;
120    }
121   
122    /**
123    * @param label the entity label
124    * @return the changes for the specified entity
125    */
 
126  10 toggle public EntityDiff getEntityDiff(String label)
127    {
128  10 return new EntityDiff(this.container.findElement(By
129    .xpath("//dd[parent::dl[@class = 'diff-group'] and preceding-sibling::dt[normalize-space(.) = '" + label
130    + "']]")));
131    }
132    }