| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| WidgetTextDescription |
|
| 1.0;1 |
| 1 | /******************************************************************************* | |
| 2 | * Copyright (c) 2008 Ketan Padegaonkar and others. | |
| 3 | * All rights reserved. This program and the accompanying materials | |
| 4 | * are made available under the terms of the Eclipse Public License v1.0 | |
| 5 | * which accompanies this distribution, and is available at | |
| 6 | * http://www.eclipse.org/legal/epl-v10.html | |
| 7 | * | |
| 8 | * Contributors: | |
| 9 | * Ketan Padegaonkar - initial API and implementation | |
| 10 | *******************************************************************************/ | |
| 11 | package org.eclipse.swtbot.swt.finder.utils; | |
| 12 | ||
| 13 | import org.eclipse.swt.widgets.Widget; | |
| 14 | import org.hamcrest.Description; | |
| 15 | import org.hamcrest.SelfDescribing; | |
| 16 | import org.hamcrest.StringDescription; | |
| 17 | ||
| 18 | /** | |
| 19 | * Describes the widget, by invoking {@link SWTUtils#getText(Object)} on the widget. | |
| 20 | * | |
| 21 | * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com> | |
| 22 | * @version $Id$ | |
| 23 | */ | |
| 24 | public class WidgetTextDescription implements SelfDescribing { | |
| 25 | ||
| 26 | private final Widget widget; | |
| 27 | ||
| 28 | 629 | public WidgetTextDescription(Widget widget) { |
| 29 | 629 | this.widget = widget; |
| 30 | 629 | } |
| 31 | ||
| 32 | public void describeTo(Description description) { | |
| 33 | 644 | description.appendText(ClassUtils.simpleClassName(widget) + " with text {" + SWTUtils.toString(widget) + "}"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 34 | 644 | } |
| 35 | ||
| 36 | public String toString() { | |
| 37 | 1 | return StringDescription.asString(this); |
| 38 | } | |
| 39 | ||
| 40 | } |