Skip to content

Package: StrategyTestUtil$1

StrategyTestUtil$1

nameinstructionbranchcomplexitylinemethod
getFailureMessage()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
test()
M: 0 C: 9
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
{...}
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2019 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Lucas Koehler - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.view.multisegment.tooling;
15:
16: import org.eclipse.swt.widgets.Shell;
17: import org.eclipse.swtbot.swt.finder.SWTBot;
18: import org.eclipse.swtbot.swt.finder.waits.Conditions;
19: import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
20:
21: /**
22: * Utility methods for testing the reference service strategies.
23: *
24: * @author Lucas Koehler
25: *
26: */
27: final class StrategyTestUtil {
28:
29:         private StrategyTestUtil() {
30:                 // utility class
31:         }
32:
33:         /**
34:          * Waits until the {@link Shell} with the given title is active. The active shell is checked every 100 milli seconds
35:          * and the wait times out after 10 seconds.
36:          *
37:          * @param title The title of the {@link Shell}.
38:          */
39:         static void waitForShell(String title) {
40:                 new SWTBot().waitUntil(Conditions.shellIsActive(title), 10000, 100);
41:         }
42:
43:         /**
44:          * Waits until the element at index 0 of the given array is not null. The check is repeated every 100 milli seconds
45:          * and the wait times out after 20 seconds.
46:          *
47:          * @param array The array which will contain the wanted element at index 0
48:          * @return the result if the wait succeeds
49:          */
50:         static <T> T waitUntilNotNull(T[] array) {
51:                 new SWTBot().waitUntil(new DefaultCondition() {
52:
53:                         @Override
54:                         public boolean test() throws Exception {
55:•                                return array[0] != null;
56:                         }
57:
58:                         @Override
59:                         public String getFailureMessage() {
60:                                 return "Strategy did not return!"; //$NON-NLS-1$
61:                         }
62:                 }, 20000, 100);
63:                 return array[0];
64:         }
65: }