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

File ProgressBarPane.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

2
6
3
1
75
26
4
0.67
2
3
1.33

Classes

Class Line # Actions
ProgressBarPane 35 6 0% 4 1
0.9090909490.9%
 

Contributing tests

This file is covered by 1 test. .

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.regex.Matcher;
23    import java.util.regex.Pattern;
24   
25    import org.openqa.selenium.By;
26    import org.openqa.selenium.WebElement;
27    import org.xwiki.test.ui.po.BaseElement;
28   
29    /**
30    * Displays a generic progress bar.
31    *
32    * @version $Id: d642108bc109a182730a7bebe41736300f825fa9 $
33    * @since 4.2M1
34    */
 
35    public class ProgressBarPane extends BaseElement
36    {
37    /**
38    * The pattern used to extract the progress percent. Note that the process percent is a positive integer.
39    */
40    private static final Pattern PERCENT_PATTERN = Pattern.compile("(\\d+)%");
41   
42    /**
43    * The progress bar container.
44    */
45    private final WebElement container;
46   
47    /**
48    * Creates a new instance.
49    *
50    * @param container the progress bar container
51    */
 
52  1 toggle public ProgressBarPane(WebElement container)
53    {
54  1 this.container = container;
55    }
56   
57    /**
58    * @return the progress percent
59    */
 
60  1 toggle public int getPercent()
61    {
62  1 WebElement progressBar = getDriver().findElementWithoutWaiting(container, By.className("ui-progress-bar"));
63  1 String style = progressBar.getAttribute("style");
64  1 Matcher matcher = PERCENT_PATTERN.matcher(style);
65  1 return matcher.find() ? Integer.parseInt(matcher.group(1)) : -1;
66    }
67   
68    /**
69    * @return the progress message, displayed below the progress bar
70    */
 
71  2 toggle public String getMessage()
72    {
73  2 return getDriver().findElementWithoutWaiting(container, By.className("ui-progress-message")).getText();
74    }
75    }