diff options
author | Jani Laakso <jani.laakso@itmill.com> | 2008-04-07 15:38:15 +0000 |
---|---|---|
committer | Jani Laakso <jani.laakso@itmill.com> | 2008-04-07 15:38:15 +0000 |
commit | f51577b7567821f8bb13ecaa60eb101f708e6147 (patch) | |
tree | 10cef62ed79d94aba6e83d76f0b753f1f3cc1410 /src/com/itmill/toolkit/automatedtests/util/DebugId.java | |
parent | 638fe9899be27b8f4f92dc4750f813c1210ecb1f (diff) | |
download | vaadin-framework-f51577b7567821f8bb13ecaa60eb101f708e6147.tar.gz vaadin-framework-f51577b7567821f8bb13ecaa60eb101f708e6147.zip |
Created com.itmill.toolkit.automatedtests package which contains "official" automated tests
* do not touch them unless you change automated test client's testcase scripts too.
* copy your testing application to package com.itmill.toolkit.automatedtests
* do not point to "development / testing / production" packages which are edited in the future without relation to testing
* use setDebugId's for all components that are used in testing
Moved few classes from "experimental" com.itmill.toolkit.tests package into "official" side.
Copied featurebrowser to automatedtests package and added setDebugId's for most components that are used in the testing.
svn changeset:4138/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/automatedtests/util/DebugId.java')
-rw-r--r-- | src/com/itmill/toolkit/automatedtests/util/DebugId.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/com/itmill/toolkit/automatedtests/util/DebugId.java b/src/com/itmill/toolkit/automatedtests/util/DebugId.java new file mode 100644 index 0000000000..03dc6cedec --- /dev/null +++ b/src/com/itmill/toolkit/automatedtests/util/DebugId.java @@ -0,0 +1,49 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + +package com.itmill.toolkit.automatedtests.util; + +import java.util.HashMap; + +import com.itmill.toolkit.ui.Component; + +public class DebugId { + + private static HashMap debugIds = new HashMap(); + + /** + * Generate static debug id based on package and component type. If + * duplicate package, component type then number of instances count is + * appended to debugId. + * + * @param c + */ + public static void set(Component c, String description) { + String debugId = ""; + + // add package name + StackTraceElement[] st = new Throwable().fillInStackTrace() + .getStackTrace(); + try { + debugId += st[3].getClassName(); + } catch (Exception e) { + e.printStackTrace(); + } + + // add component type + debugId += c.getClass(); + + // add given description + debugId += description; + + if (debugIds.containsKey(debugId)) { + int count = ((Integer) debugIds.get(debugId)).intValue(); + count++; + debugIds.put(debugId, new Integer(count)); + debugId = debugId + "-" + count; + } + + c.setDebugId(debugId); + } +} |