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

File ExtensionDependenciesPane.java

 

Coverage histogram

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

Code metrics

2
10
5
1
96
45
6
0.6
2
5
1.2

Classes

Class Line # Actions
ExtensionDependenciesPane 38 10 0% 6 0
1.0100%
 

Contributing tests

This file is covered by 5 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.extension.test.po;
21   
22    import java.util.ArrayList;
23    import java.util.List;
24   
25    import org.openqa.selenium.By;
26    import org.openqa.selenium.WebDriver;
27    import org.openqa.selenium.WebElement;
28    import org.openqa.selenium.support.ui.ExpectedCondition;
29    import org.xwiki.test.ui.XWikiWebDriver;
30    import org.xwiki.test.ui.po.BaseElement;
31   
32    /**
33    * The section that displays the extension dependencies.
34    *
35    * @version $Id: 76b42651180a5733e83055fa76020229ad06f1e6 $
36    * @since 4.2M1
37    */
 
38    public class ExtensionDependenciesPane extends BaseElement
39    {
40    /**
41    * The section container.
42    */
43    private final WebElement container;
44   
45    /**
46    * Creates a new instance.
47    *
48    * @param container the section container
49    */
 
50  8 toggle public ExtensionDependenciesPane(WebElement container)
51    {
52  8 this.container = container;
53    }
54   
55    /**
56    * @return the list of direct dependencies
57    */
 
58  2 toggle public List<DependencyPane> getDirectDependencies()
59    {
60    // Wait until all remote dependencies are resolved asynchronously.
61  2 getDriver().waitUntilCondition(new ExpectedCondition<WebElement>()
62    {
 
63  3 toggle @Override
64    public WebElement apply(WebDriver driver)
65    {
66  3 return ((XWikiWebDriver) driver).findElementsWithoutWaiting(container,
67    By.className("extension-item-loading")).size() > 0 ? null : container;
68    }
69    });
70  2 return getDependenciesAfter("This extension depends on:");
71    }
72   
73    /**
74    * @return the list of backward dependencies
75    */
 
76  2 toggle public List<DependencyPane> getBackwardDependencies()
77    {
78  2 return getDependenciesAfter("This extension is required by:");
79    }
80   
81    /**
82    * @param label the text that precedes the list of dependencies
83    * @return the list of dependencies after the specified label
84    */
 
85  9 toggle List<DependencyPane> getDependenciesAfter(String label)
86    {
87  9 By xpath =
88    By.xpath(".//*[contains(@class, 'dependency-item') and ancestor::dd[preceding-sibling::dt[starts-with(., '"
89    + label + "')]]]");
90  9 List<DependencyPane> dependencies = new ArrayList<DependencyPane>();
91  9 for (WebElement element : getDriver().findElementsWithoutWaiting(container, xpath)) {
92  15 dependencies.add(new DependencyPane(element));
93    }
94  9 return dependencies;
95    }
96    }