Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 59269 Details for
Bug 165935
Some AGR test suites need to be refactored
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
LaunchPart3_VerificationHookClass
PlatformUIProfilingPerspectiveLaunchPart3.java (text/plain), 28.72 KB, created by
Liz Dancy
on 2007-02-19 11:05:07 EST
(
hide
)
Description:
LaunchPart3_VerificationHookClass
Filename:
MIME Type:
Creator:
Liz Dancy
Created:
2007-02-19 11:05:07 EST
Size:
28.72 KB
patch
obsolete
>package org.eclipse.hyades.use.cases.auto.profiling.logging; > >import java.util.ArrayList; > >import org.eclipse.hyades.use.cases.auto.common.Logger; >import org.eclipse.hyades.use.cases.auto.common.VerifyHookUtil; >import org.eclipse.swt.widgets.Composite; >import org.eclipse.swt.widgets.Tree; >import org.eclipse.swt.widgets.TreeColumn; >import org.eclipse.swt.widgets.TreeItem; >import org.eclipse.tptp.test.auto.gui.internal.runner.AutoGUIVerificationHook; > >/** > * Generated code for the test suite <b>Platform.UI.ProfilingPerspective.Launch.Part4</b> located at > * <i>/org.eclipse.hyades.use.cases/gui/Profiling_and_Logging/Platform.UI.ProfilingPerspective.Launch.Part4.testsuite</i>. > */ >/* > * Author: Mike Hao > */ >public class PlatformUIProfilingPerspectiveLaunchPart3 extends > AutoGUIVerificationHook { > > /** > * Constructor for PlatformUIProfilingPerspectiveLaunchPart4. An instance of this class is created to > * test a test method. > * > * @param testMethodName The test method to be tested. > * @param paramTypes The parameter types of the test method > * @param args The arguments of the test method > */ > public PlatformUIProfilingPerspectiveLaunchPart3(String testMethodName, > Class[] paramTypes, Object[] args) { > super(testMethodName, paramTypes, args); > } > > /** > * @see junit.framework.TestCase#setUp() > */ > protected void setUp() throws Exception { > } > > /** > * @see junit.framework.TestCase#tearDown() > */ > protected void tearDown() throws Exception { > Logger.getInstance().close(); > } > > /** > * Verify Memory Statistics package level information. > * <p> > * <b>Testing Steps:</b> > * <ol> > * <li>Profile a Java application, make sure the <b>Memory Analysis</b> profile type is selected.</li> > * <li>Open <b>Memory Statistics</b> view (package level), verify the following information:</li> > * <ul><li>Total Instances and Live Instances are greater than 0</li> > * <li>Total Instances are greater than or equal Live Instances</li> > * <li>Collected instances are greater than or equal 0</li> > * <li>Total Size is greater than or equals Active Size</li> > * <li>The actual instances of the profiled application has the expected values</li> > * </ul> > * </ol> > * <p> > * <b>Purpose:</b> Perform the verification in step #2 > * @throws Exception > */ > public void verifyMemoryStatisticsPackageLevel(org.eclipse.ui.IViewPart arg0) > throws Exception > { > Logger.getInstance().logMessage(Logger.INFO, "Entering verifyMemoryStatisticsPackageLevel"); > > Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); > assertNotNull (memoryStatisticsView); > Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null); > assertNotNull (tree); > TreeItem[] treeItems = tree.getItems(); > > int len = 0; > > for(int i = 0; i < treeItems.length; i++){ > len += treeItems[i].getItems().length; > } > > TreeItem[] subTreeItems = new TreeItem[len]; > int k = 0; > > for(int i = 0; i < treeItems.length; i++){ > TreeItem[] items = treeItems[i].getItems(); > > for(int j = 0; j < items.length; j++, k++){ > subTreeItems[k] = items[j]; > } > } > > String[] apps = new String[]{"[int", "[char", "[byte", "[short", "[long", "HelloWorld", "Class"}; > > verifyInstanceDetails(tree, treeItems, apps); > verifySizeDetails(tree, subTreeItems, apps); > verifyAppInstances(tree, subTreeItems, "HelloWorld", 1, 1); > > Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyMemoryStatisticsPackageLevel"); > } > > /** > * Verify Memory Statistics class level information. > * <p> > * <b>Testing Steps:</b> > * <ol> > * <li>Profile a Java application, make sure the <b>Memory Analysis</b> profile type is selected.</li> > * <li>Open <b>Memory Statistics</b> view (class level), verify the following information:</li> > * <ul><li>Total Instances and Live Instances are greater than 0</li> > * <li>Total Instances are greater than or equal Live Instances</li> > * <li>Collected instances are greater than or equal 0</li> > * <li>Total Size is greater than or equals Active Size</li> > * <li>The actual instances of the profiled application has the expected values</li> > * </ul> > * </ol> > * <p> > * <b>Purpose:</b> Perform the verification in step #2 > * @throws Exception > */ > public void verifyMemoryStatisticsClassLevel(org.eclipse.ui.IViewPart arg0) > throws Exception > { > Logger.getInstance().logMessage(Logger.INFO, "Entering verifyMemoryStatiticsClassLevel"); > > Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); > assertNotNull (memoryStatisticsView); > Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null); > assertNotNull (tree); > TreeItem[] treeItems = tree.getItems(); > > String[] apps = new String[]{"[int", "[char", "[byte", "[short", "[long", "HelloWorld", "Class"}; > > verifyInstanceDetails(tree, treeItems, apps); > verifySizeDetails(tree, treeItems, apps); > verifyAppInstances(tree, treeItems, "HelloWorld", 1, 1); > > Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyMemoryStatiticsClassLevel"); > } > > /** > * Verify Memory Statistics instances level information. > * <p> > * <b>Testing Steps:</b> > * <ol> > * <li>Profile a Java application, make sure the <b>Memory Analysis</b> profile type is selected.</li> > * <li>Open <b>Memory Statistics</b> view (instances level), verify the following information:</li> > * <ul><li>Total Size is greater than or equals Active Size</li></ul> > * </ol> > * <p> > * <b>Purpose:</b> Perform the verification in step #2 > * @throws Exception > */ > public void verifyMemoryStatisticsInstanceLevel(org.eclipse.ui.IViewPart arg0) > throws Exception > { > Logger.getInstance().logMessage(Logger.INFO, "Entering verifyMemoryStatisticsInstanceLevel"); > > Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); > assertNotNull (memoryStatisticsView); > Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null); > assertNotNull (tree); > TreeItem[] treeItems = tree.getItems(); > > /* for Instances level, only check Instance Size infomation */ > verifySizeDetails(tree, treeItems, new String[]{"[int", "[char", "[byte", "[short", "[long", "HelloWorld", "Class"}); > > Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyMemoryStatisticsInstanceLevel"); > } > > /** > * Verify Execution Statistics package level information. > * <p> > * <b>Testing Steps:</b> > * <ol> > * <li>Profile a Java application, make sure the <b>Execution History</b> profile type is selected.</li> > * <li>Open <b>Execution Statistics</b> view (package level), verify the following information:</li> > * <ul><li>Base Time, Average Base Time and Cumulative Time are greater than or equal 0</li> > * <li>Calls for each method is greater than or equal 0</li> > * <li>Calls for an expected method is equalled to the number of times it is invoked</li> > * <li>Base Time and Cumulative Time of the method are greater that or equal the argument to the sleep method</li> > * <li>The actual instances of the profiled application has the expected values</li> > * </ul> > * </ol> > * <p> > * <b>Purpose:</b> Perform the verification in step #2 > * @throws Exception > */ > public void verifyExecutionStatisticsPackageLevel(org.eclipse.ui.IViewPart arg0) > throws Exception > { > Logger.getInstance().logMessage(Logger.INFO, "Entering verifyExecutionStatisticsPackageLevel"); > > Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); > assertNotNull (memoryStatisticsView); > Tree tree = (Tree)VerifyHookUtil.findAllControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null)[1]; > assertNotNull (tree); > TreeItem[] treeItems = ((tree.getItems())[0].getItems())[0].getItems(); > verifyTimesDetails(tree, treeItems, new String[]{"main(java.lang.String[]) void", "Limits()", "methodA(int) void", "methodB() void"}, 0); > /* methodB sleeps for 5 seconds, verify that the times for methodB >= 0.5 seconds */ > verifyTimesDetails(tree, treeItems, new String[]{"methodB() void"}, 0.5f); > verifyCallsDetails(tree, treeItems, new String[]{"main(java.lang.String[]) void", "Limits()", "methodA(int) void", "methodB() void"}, 0); > /* verify calls for methodA = 10 */ > verifyCallsDetails(tree, treeItems, new String[]{"methodA(int) void"}, 10, true); > /* verify calls for methodB = 1 */ > verifyCallsDetails(tree, treeItems, new String[]{"methodB() void"}, 1, true); > > Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyExecutionStatisticsPackageLevel"); > } > > /** > * Verify Execution Statistics class level information. > * <p> > * <b>Testing Steps:</b> > * <ol> > * <li>Profile a Java application, make sure the <b>Execution History</b> profile type is selected.</li> > * <li>Open <b>Execution Statistics</b> view (class level), verify the following information:</li> > * <ul><li>Base Time, Average Base Time and Cumulative Time are greater than or equal 0</li> > * <li>Calls for each method is greater than or equal 0</li> > * <li>Calls for an expected method is equalled to the number of times it is invoked</li> > * <li>Base Time and Cumulative Time of the method are greater that or equal the argument to the sleep method</li> > * <li>The actual instances of the profiled application has the expected values</li> > * </ul> > * </ol> > * <p> > * <b>Purpose:</b> Perform the verification in step #2 > * @throws Exception > */ > public void verifyExecutionStatisticsClassLevel(org.eclipse.ui.IViewPart arg0) > throws Exception > { > Logger.getInstance().logMessage(Logger.INFO, "Entering verifyExecutionStatisticsClassLevel"); > > Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); > assertNotNull (memoryStatisticsView); > Tree tree = (Tree)VerifyHookUtil.findAllControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null)[1]; > assertNotNull (tree); > TreeItem[] treeItems = (tree.getItems())[0].getItems(); > > verifyTimesDetails(tree, treeItems, new String[]{"main(java.lang.String[]) void", "Limits()", "methodA(int) void", "methodB() void"}, 0); > /* methodB sleeps for 5 seconds, verify that the times for methodB >= 0.5 seconds */ > verifyTimesDetails(tree, treeItems, new String[]{"methodB() void"}, 0.5f); > verifyCallsDetails(tree, treeItems, new String[]{"main(java.lang.String[]) void", "Limits()", "methodA(int) void", "methodB() void"}, 0); > /* verify calls for methodA = 10 */ > verifyCallsDetails(tree, treeItems, new String[]{"methodA(int) void"}, 10, true); > /* verify calls for methodB = 1 */ > verifyCallsDetails(tree, treeItems, new String[]{"methodB() void"}, 1, true); > > Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyExecutionStatisticsClassLevel"); > } > > /** > * Verify Execution Statistics method level information. > * <p> > * <b>Testing Steps:</b> > * <ol> > * <li>Profile a Java application, make sure the <b>Execution History</b> profile type is selected.</li> > * <li>Open <b>Execution Statistics</b> view (method level), verify the following information:</li> > * <ul><li>Base Time, Average Base Time and Cumulative Time are greater than or equal 0</li> > * <li>Calls for each method is greater than or equal 0</li> > * <li>Calls for an expected method is equalled to the number of times it is invoked</li> > * <li>Base Time and Cumulative Time of the method are greater that or equal the argument to the sleep method</li> > * <li>The actual instances of the profiled application has the expected values</li> > * </ul> > * </ol> > * <p> > * <b>Purpose:</b> Perform the verification in step #2 > * @throws Exception > */ > public void verifyExecutionStatisticsMethodLevel(org.eclipse.ui.IViewPart arg0) > throws Exception > { > Logger.getInstance().logMessage(Logger.INFO, "Entering verifyExecutionStatisticsMethodLevel"); > > Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); > assertNotNull (memoryStatisticsView); > Tree tree = (Tree)VerifyHookUtil.findAllControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null)[1]; > assertNotNull (tree); > TreeItem[] treeItems = tree.getItems(); > > verifyTimesDetails(tree, treeItems, new String[]{"main(java.lang.String[]) void", "Limits()", "methodA(int) void", "methodB() void"}, 0); > /* methodB sleeps for 5 seconds, verify that the times for methodB >= 0.5 seconds */ > verifyTimesDetails(tree, treeItems, new String[]{"methodB() void"}, 0.5f); > verifyCallsDetails(tree, treeItems, new String[]{"main(java.lang.String[]) void", "Limits()", "methodA(int) void", "methodB() void"}, 0); > /* verify calls for methodA = 10 */ > verifyCallsDetails(tree, treeItems, new String[]{"methodA(int) void"}, 10, true); > /* verify calls for methodB = 1 */ > verifyCallsDetails(tree, treeItems, new String[]{"methodB() void"}, 1, true); > > Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyExecutionStatisticsMethodLevel"); > } > > /** > * Verify Execution Statistics instances level information. > * <p> > * <b>Testing Steps:</b> > * <ol> > * <li>Profile a Java application, make sure the <b>Execution History</b> profile type is selected.</li> > * <li>Open <b>Execution Statistics</b> view (instances level), verify the following information:</li> > * <ul><li>Base Time, Average Base Time and Cumulative Time are greater than or equal 0</li> > * <li>Calls for each method is greater than or equal 0</li> > *</ul> > * </ol> > * <p> > * <b>Purpose:</b> Perform the verification in step #2 > * @throws Exception > */ > public void verifyExecutionStatisticsInstancesLevel(org.eclipse.ui.IViewPart arg0) > throws Exception > { > Logger.getInstance().logMessage(Logger.INFO, "Entering verifyExecutionStatisticsInstancesLevel"); > > Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); > assertNotNull (memoryStatisticsView); > Tree tree = (Tree)VerifyHookUtil.findAllControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null)[1]; > assertNotNull (tree); > TreeItem[] treeItems = tree.getItems(); > > /* verify times for all methods >= 0 */ > verifyTimesDetails(tree, treeItems, new String[]{"Limits"}, 0); > /* verify calls for all methods >= 0 */ > verifyCallsDetails(tree, treeItems, new String[]{"Limits"}, 0); > > Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyExecutionStatisticsInstancesLevel"); > } > > /** > * Verify Code Coverage package level information. > * <p> > * <b>Testing Steps:</b> > * <ol> > * <li>Profile a Java application, make sure the <b>Code Coverage</b> profile type is selected.</li> > * <li>Open <b>Code Coverage</b> view (package level), verify the following information:</li> > * <ul><li>Calls for each method is greater than or equal 0</li> > * <li>Method Hit(%) for the profiled class is greater than or equals 0</li> > * <li>Expected methods missed have 'missed' in the 'Method missed' column</li> > * <li>Expected methods hit have 'hit' in the 'Methods hit' column</li> > * </ul> > * </ol> > * <p> > * <b>Purpose:</b> Perform the verification in step #2 > * @throws Exception > */ > public void verifyCodeCoveragePackageLevel(org.eclipse.ui.IViewPart arg0) > throws Exception > { > Logger.getInstance().logMessage(Logger.INFO, "Entering verifyCodeCoveragePackageLevel"); > > Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); > assertNotNull (memoryStatisticsView); > Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null); > assertNotNull (tree); > TreeItem[] treeItems = ((tree.getItems())[0].getItems())[0].getItems(); > TreeItem[] leafItems = treeItems[0].getItems(); > > /* verify %Methods Hit >= 0 */ > verifyMethodsHitPercentage(tree, treeItems, new String[]{"Limits"}, 0); > /* verify method which hit */ > verifyMethodsHit(tree, leafItems, new String[]{"main(java.lang.String[]) void", "Limits()", "methodA(int) void"}); > verifyMethodsMissed(tree, leafItems, new String[]{"methodC() void"}); > verifyCallsDetails(tree, leafItems, new String[]{"main(java.lang.String[]) void", "Limits()", "methodA(int) void", "methodB() void", "methodC() void"}, 0); > > Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyCodeCoveragePackageLevel"); > } > > /** > * Verify Code Coverage class level information. > * <p> > * <b>Testing Steps:</b> > * <ol> > * <li>Profile a Java application, make sure the <b>Code Coverage</b> profile type is selected.</li> > * <li>Open <b>Code Coverage</b> view (class level), verify the following information:</li> > * <ul><li>Calls for each method is greater than or equal 0</li> > * <li>Method Hit(%) for the profiled class is greater than or equals 0</li> > * <li>Expected methods missed have 'missed' in the 'Method missed' column</li> > * <li>Expected methods hit have 'hit' in the 'Methods hit' column</li> > * </ul> > * </ol> > * <p> > * <b>Purpose:</b> Perform the verification in step #2 > * @throws Exception > */ > public void verifyCodeCoverageClassLevel(org.eclipse.ui.IViewPart arg0) > throws Exception > { > Logger.getInstance().logMessage(Logger.INFO, "Entering verifyCodeCoverageClassLevel"); > > Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); > assertNotNull (memoryStatisticsView); > Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null); > assertNotNull (tree); > TreeItem[] treeItems = (tree.getItems())[0].getItems(); > TreeItem[] leafItems = treeItems[0].getItems(); > > /* verify %Methods Hit >= 0 */ > verifyMethodsHitPercentage(tree, treeItems, new String[]{"Limits"}, 0); > /* verify method which hit */ > verifyMethodsHit(tree, leafItems, new String[]{"main(java.lang.String[]) void", "Limits()", "methodA(int) void"}); > verifyMethodsMissed(tree, leafItems, new String[]{"methodC() void"}); > verifyCallsDetails(tree, leafItems, new String[]{"main(java.lang.String[]) void", "Limits()", "methodA(int) void", "methodB() void", "methodC() void"}, 0); > > Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyCodeCoverageClassLevel"); > } > > /** > * Verify Code Coverage method level information. > * <p> > * <b>Testing Steps:</b> > * <ol> > * <li>Profile a Java application, make sure the <b>Code Coverage</b> profile type is selected.</li> > * <li>Open <b>Code Coverage</b> view (method level), verify the following information:</li> > * <ul><li>Calls for each method is greater than or equal 0</li> > * <li>Method Hit(%) for the profiled class is greater than or equals 0</li> > * <li>Expected methods missed have 'missed' in the 'Method missed' column</li> > * <li>Expected methods hit have 'hit' in the 'Methods hit' column</li> > * </ul> > * </ol> > * <p> > * <b>Purpose:</b> Perform the verification in step #2 > * @throws Exception > */ > public void verifyCodeCoverageMethodLevel(org.eclipse.ui.IViewPart arg0) > throws Exception > { > Logger.getInstance().logMessage(Logger.INFO, "Entering verifyCodeCoverageMethodLevel"); > > Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); > assertNotNull (memoryStatisticsView); > Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null); > assertNotNull (tree); > TreeItem[] treeItems = tree.getItems(); > TreeItem[] leafItems = treeItems[0].getItems(); > > /* verify %Methods Hit >= 0 */ > verifyMethodsHitPercentage(tree, treeItems, new String[]{"<--Summary-->"}, 0); > /* verify method which hit */ > verifyMethodsHit(tree, leafItems, new String[]{"main(java.lang.String[]) void", "Limits()", "methodA(int) void"}); > verifyMethodsMissed(tree, leafItems, new String[]{"methodC() void"}); > verifyCallsDetails(tree, leafItems, new String[]{"main(java.lang.String[]) void", "Limits()", "methodA(int) void", "methodB() void", "methodC() void"}, 0); > > Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyCodeCoverageMethodLevel"); > } > > private void verifyInstanceDetails(Tree tree, TreeItem[] treeItems, String[] names){ > > int totalInstancesClmnIndex = getTreeColumnIndex(tree, "Total Instances"); > int liveInstancesClmnIndex = getTreeColumnIndex(tree, "Live Instances"); > int collectedClmnIndex = getTreeColumnIndex(tree, "Collected"); > > int[] indexes = getTreeItemIndexes(treeItems, names); > > ArrayList totalInstances = new ArrayList(); > ArrayList liveInstances = new ArrayList(); > ArrayList collectedInstances = new ArrayList(); > > for(int i = 0; i < treeItems.length; i++){ > if(isIn(i, indexes)){ > totalInstances.add(treeItems[i].getText(totalInstancesClmnIndex)); > liveInstances.add(treeItems[i].getText(liveInstancesClmnIndex)); > collectedInstances.add(treeItems[i].getText(collectedClmnIndex)); > } > } > > Object[] totalInstanceObj = totalInstances.toArray(); > Object[] liveInstanceObj = liveInstances.toArray(); > Object[] collectedObj = collectedInstances.toArray(); > > for(int j = 0; j < totalInstanceObj.length; j++){ > int totalInst = Integer.parseInt((String)totalInstanceObj[j]); > int liveInst = Integer.parseInt((String)liveInstanceObj[j]); > int collected = Integer.parseInt((String)collectedObj[j]); > > assertTrue(totalInst >= 0); > assertTrue(liveInst >= 0); > assertTrue(totalInst >= liveInst); > assertTrue(collected >= 0); > } > } > > private void verifySizeDetails(Tree tree, TreeItem[] treeItems, String[] names){ > > int totalSizeClmnIndex = getTreeColumnIndex(tree, "Total Size (bytes)"); > int activeSizeClmnIndex = getTreeColumnIndex(tree, "Active Size (bytes)"); > int[] indexes = getTreeItemIndexes(treeItems, names); > > ArrayList totalSize = new ArrayList(); > ArrayList activeSize = new ArrayList(); > > for(int i = 0; i < treeItems.length; i++){ > if(isIn(i, indexes)){ > totalSize.add(treeItems[i].getText(totalSizeClmnIndex)); > activeSize.add(treeItems[i].getText(activeSizeClmnIndex)); > } > } > > /* This section verifies following requirments: > - Total Size >= Active Size */ > Object[] totalSizeObj = totalSize.toArray(); > Object[] activeSizeObj = activeSize.toArray(); > > for(int j = 0; j < totalSizeObj.length; j++){ > int totalSz = Integer.parseInt((String)totalSizeObj[j]); > int activeSz = Integer.parseInt((String)activeSizeObj[j]); > > assertTrue(totalSz >= activeSz); > } > } > > private boolean isIn(int index, int[] nums){ > for(int i = 0; i < nums.length; i++){ > if(index == nums[i]){ > return true; > } > } > return false; > } > > private void verifyAppInstances(Tree tree, TreeItem[] treeItems, String app, int totalExpected, int activeExpected){ > > int totalInstancesClmnIndex = getTreeColumnIndex(tree, "Total Instances"); > int liveInstancesClmnIndex = getTreeColumnIndex(tree, "Live Instances"); > > int appItemIndex = getTreeItemIndex(treeItems, app); > > int appTotalInst = 0; > int appLiveInst = 0; > > for(int i = 0; i < treeItems.length; i++){ > if( i == appItemIndex ){ > appTotalInst = Integer.parseInt((String)treeItems[i].getText(totalInstancesClmnIndex)); > appLiveInst = Integer.parseInt((String)treeItems[i].getText(liveInstancesClmnIndex)); > } > } > > /* verify the Total Instances and Live Instances of App */ > assertEquals(appTotalInst, totalExpected); > assertEquals(appLiveInst, activeExpected); > } > > private int getTreeItemIndex(TreeItem[] items, String item){ > int index = -1; > > for(int i = 0; i < items.length; i++){ > if(items[i].getText().trim().equals(item.trim())){ > index = i; > break; > } > } > return index; > } > > private int[] getTreeItemIndexes(TreeItem[] items, String[] names){ > > int[] indexes = new int[names.length]; > > for(int i = 0; i < names.length; i++){ > indexes[i] = getTreeItemIndex(items, names[i]); > } > return indexes; > } > > private int getTreeColumnIndex(Tree tree, String column){ > int index = -1; > > TreeColumn[] columns = tree.getColumns(); > for(int i = 0; i < columns.length; i++){ > if(columns[i].getText().trim().equals(column.trim())){ > index = i; > break; > } > } > return index; > } > > private void verifyTimesDetails(Tree tree, TreeItem[] treeItems, String[] names, float seconds){ > > int baseTimeClmnIndex = getTreeColumnIndex(tree, "Base Time (seconds)"); > int avgBaseTimeClmnIndex = getTreeColumnIndex(tree, "Average Base Time (seconds)"); > int cumulativeTimeClmnIndex = getTreeColumnIndex(tree, "Cumulative Time (seconds)"); > int[] indexes = getTreeItemIndexes(treeItems, names); > float sleepAcct = 0.1f; // Thread.sleep() accuracy is +/- 0.1 seconds > > ArrayList baseTime = new ArrayList(); > ArrayList avgTime = new ArrayList(); > ArrayList cumulativeTime = new ArrayList(); > > for(int i = 0; i < treeItems.length; i++){ > if(isIn(i, indexes)){ > baseTime.add(treeItems[i].getText(baseTimeClmnIndex)); > avgTime.add(treeItems[i].getText(avgBaseTimeClmnIndex)); > cumulativeTime.add(treeItems[i].getText(cumulativeTimeClmnIndex)); > } > } > > /* This section verifies following requirments: > - All times >= 0 > */ > Object[] baseTimeObj = baseTime.toArray(); > Object[] avgTimeObj = avgTime.toArray(); > Object[] cumulativeTimeObj = cumulativeTime.toArray(); > > assertTrue(baseTimeObj.length > 0); > > for(int j = 0; j < baseTimeObj.length; j++){ > assertTrue(Float.compare(Float.parseFloat((String)baseTimeObj[j]), (seconds - sleepAcct)) >= 0); > > /* No Average Time column for Instances Level view */ > if(avgBaseTimeClmnIndex != -1){ > assertTrue(Float.compare(Float.parseFloat((String)avgTimeObj[j]), seconds - sleepAcct) >= 0); > } > > assertTrue(Float.compare(Float.parseFloat((String)cumulativeTimeObj[j]), seconds - sleepAcct) >= 0); > } > } > > private void verifyCallsDetails(Tree tree, TreeItem[] treeItems, String[] names, int callTimes){ > verifyCallsDetails(tree, treeItems, names, callTimes, false); > } > > private void verifyCallsDetails(Tree tree, TreeItem[] treeItems, String[] names, int callTimes, boolean equal){ > > int callsClmnIndex = getTreeColumnIndex(tree, "Calls"); > int[] indexes = getTreeItemIndexes(treeItems, names); > > ArrayList calls = new ArrayList(); > > for(int i = 0; i < treeItems.length; i++){ > if(isIn(i, indexes)){ > calls.add(treeItems[i].getText(callsClmnIndex)); > } > } > > /* This section verifies following requirments: calls >= callTimes */ > Object[] callsObj = calls.toArray(); > > assertTrue(callsObj.length > 0); > > for(int j = 0; j < callsObj.length; j++){ > if(equal){ > assertTrue(Integer.parseInt((String)callsObj[j]) == callTimes); > }else{ > assertTrue(Integer.parseInt((String)callsObj[j]) >= callTimes); > } > } > } > > > private void verifyMethodsHitPercentage(Tree tree, TreeItem[] treeItems, > String[] names, int percentage) { > > int hitPctClmnIndex = getTreeColumnIndex(tree, "% Methods Hit"); > int[] indexes = getTreeItemIndexes(treeItems, names); > > ArrayList hitPct = new ArrayList(); > > for (int i = 0; i < treeItems.length; i++) { > if (isIn(i, indexes)) { > hitPct.add(treeItems[i].getText(hitPctClmnIndex)); > } > } > > /* This section verifies following requirments: %Method Hit >= 0 */ > Object[] hitPctObj = hitPct.toArray(); > > assertTrue(hitPctObj.length > 0); > > for (int j = 0; j < hitPctObj.length; j++) { > String hitPctStr = (String) hitPctObj[j]; > String hits = hitPctStr.substring(0, hitPctStr.indexOf("%")); > > assertTrue(Float.compare(Float.parseFloat(hits), percentage) >= 0); > } > } > > private void verifyMethodsHit(Tree tree, TreeItem[] treeItems, > String[] names) { > > int hitClmnIndex = getTreeColumnIndex(tree, "Methods hit"); > int[] indexes = getTreeItemIndexes(treeItems, names); > > ArrayList hit = new ArrayList(); > > for (int i = 0; i < treeItems.length; i++) { > if (isIn(i, indexes)) { > hit.add(treeItems[i].getText(hitClmnIndex)); > } > } > > Object[] hitObj = hit.toArray(); > > assertTrue(hitObj.length > 0); > > for (int j = 0; j < hitObj.length; j++) { > assertTrue(((String) hitObj[j]).trim().equals("hit")); > } > } > > private void verifyMethodsMissed(Tree tree, TreeItem[] treeItems, > String[] names) { > > int hitClmnIndex = getTreeColumnIndex(tree, "Methods missed"); > int[] indexes = getTreeItemIndexes(treeItems, names); > > ArrayList hit = new ArrayList(); > > for (int i = 0; i < treeItems.length; i++) { > if (isIn(i, indexes)) { > hit.add(treeItems[i].getText(hitClmnIndex)); > } > } > > Object[] hitObj = hit.toArray(); > > assertTrue(hitObj.length > 0); > > for (int j = 0; j < hitObj.length; j++) { > assertTrue(((String) hitObj[j]).trim().equals("missed")); > } > } > > > > > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 165935
:
59208
|
59209
|
59210
|
59211
|
59268
| 59269 |
59280
|
59283