[Bug 8691] Add code to allow access to functional testing of SymbianOSView from automation.utils plugin
--- a/debuggercdi/com.nokia.carbide.cpp.debug.kernelaware/META-INF/MANIFEST.MF Wed Apr 01 13:50:55 2009 -0500
+++ b/debuggercdi/com.nokia.carbide.cpp.debug.kernelaware/META-INF/MANIFEST.MF Wed Apr 01 14:49:26 2009 -0500
@@ -18,4 +18,5 @@
org.eclipse.core.resources,
com.nokia.carbide.cpp.featureTracker;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
-Export-Package: com.nokia.carbide.cpp.debug.kernelaware
+Export-Package: com.nokia.carbide.cpp.debug.kernelaware,
+ com.nokia.carbide.cpp.debug.kernelaware.testapi;x-friends:="com.nokia.carbide.automation.utils"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/debuggercdi/com.nokia.carbide.cpp.debug.kernelaware/src/com/nokia/carbide/cpp/debug/kernelaware/testapi/SymbianOSViewTester.java Wed Apr 01 14:49:26 2009 -0500
@@ -0,0 +1,129 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+package com.nokia.carbide.cpp.debug.kernelaware.testapi;
+
+import com.freescale.cdt.debug.cw.core.CWPlugin;
+import com.nokia.carbide.cpp.debug.kernelaware.*;
+import com.nokia.carbide.cpp.debug.kernelaware.ui.GenericTableTab;
+import com.nokia.carbide.cpp.debug.kernelaware.ui.SymbianOSView;
+
+import org.eclipse.jface.viewers.*;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IViewPart;
+
+/**
+ * An interface for testing the Symbian OS View
+ */
+public class SymbianOSViewTester {
+
+ /**
+ * Select a tab by id
+ * @param viewPart IViewPart
+ * @param tabId int
+ */
+ public static void selectTab(IViewPart viewPart, int tabId) {
+ TabFolder tabFolder = (TabFolder) viewPart.getAdapter(TabFolder.class);
+ tabFolder.setSelection(tabId);
+ // can't force this to notify so explicitly call notification routine
+ SymbianOSView symbianOSView = (SymbianOSView) viewPart.getAdapter(SymbianOSView.class);
+ symbianOSView.DoAction_TabSelection(tabFolder.getItem(tabId));
+ }
+
+ /**
+ * Do refresh
+ * @param viewPart IViewPart
+ */
+ public static void refresh(IViewPart viewPart) {
+ SymbianOSView symbianOSView = (SymbianOSView) viewPart.getAdapter(SymbianOSView.class);
+ symbianOSView.DoAction_Refresh();
+ }
+
+ /**
+ * Enable or disable auto refresh
+ * @param viewPart IViewPart
+ * @param enabled boolean
+ */
+ public static void setAutoRefreshEnabled(IViewPart viewPart, boolean enabled) {
+ SymbianOSView symbianOSView = (SymbianOSView) viewPart.getAdapter(SymbianOSView.class);
+ symbianOSView.setAutoRefresh(enabled);
+ }
+
+ /**
+ * Do collapse all
+ * @param viewPart IViewPart
+ */
+ public static void collapseAll(IViewPart viewPart) {
+ SymbianOSView symbianOSView = (SymbianOSView) viewPart.getAdapter(SymbianOSView.class);
+ symbianOSView.DoAction_CollapseAll();
+ }
+
+ /**
+ * Debug the process or thread
+ * @param viewPart IViewPart
+ * @param object OSObject
+ * @see OSObjectProcess
+ * @see OSObjectThread
+ */
+ public static void debug(IViewPart viewPart, OSObject object) {
+ SymbianOSView symbianOSView = (SymbianOSView) viewPart.getAdapter(SymbianOSView.class);
+ getCurrentViewer(viewPart).setSelection(new StructuredSelection(object));
+ symbianOSView.DoAction_Debug();
+ }
+
+ /**
+ * Set the auto refresh interval
+ * @param secs int
+ */
+ public static void setAutoRefreshInterval(int secs) {
+ CWPlugin.getDefault().getPluginPreferences().setValue(
+ cwdbg.PreferenceConstants.J_PN_OSViewAutoRefreshInterval, secs);
+ }
+
+ /**
+ * Get the current refresh count (increments on every refresh)
+ * @param viewPart IViewPart
+ * @return int
+ */
+ public static int getRefreshCount(IViewPart viewPart) {
+ SymbianOSView symbianOSView = (SymbianOSView) viewPart.getAdapter(SymbianOSView.class);
+ return symbianOSView.getRefreshCount();
+ }
+
+ /**
+ * Get the current viewer (TableViewer or TreeViewer depending on the selected tab)
+ * @param viewPart IViewPart
+ * @return Viewer
+ */
+ public static Viewer getCurrentViewer(IViewPart viewPart) {
+ return (Viewer) viewPart.getAdapter(Viewer.class);
+ }
+
+ /**
+ * Get the Text for the filter of the current tab
+ * This can be used with EclipseUtils.enterText(Text, String) to set the filter
+ * @param viewPart IViewPart
+ * @return Text
+ * @see EclipseUtils#enterText(Text, String)
+ */
+ public static Text getFilterText(IViewPart viewPart) {
+ Viewer viewer = getCurrentViewer(viewPart);
+ GenericTableTab tableTab = (GenericTableTab) viewer.getData("controller");
+ return tableTab.getFilterText();
+ }
+}
--- a/debuggercdi/com.nokia.carbide.cpp.debug.kernelaware/src/com/nokia/carbide/cpp/debug/kernelaware/ui/GenericTableTab.java Wed Apr 01 13:50:55 2009 -0500
+++ b/debuggercdi/com.nokia.carbide.cpp.debug.kernelaware/src/com/nokia/carbide/cpp/debug/kernelaware/ui/GenericTableTab.java Wed Apr 01 14:49:26 2009 -0500
@@ -315,6 +315,7 @@
.getDisplayName());
}
+ viewer.setData("controller", this); //$NON-NLS-1$
return viewer;
}
@@ -384,4 +385,8 @@
viewer.refresh();
}
}
+
+ public Text getFilterText() {
+ return filterText;
+ }
}
--- a/debuggercdi/com.nokia.carbide.cpp.debug.kernelaware/src/com/nokia/carbide/cpp/debug/kernelaware/ui/SymbianOSView.java Wed Apr 01 13:50:55 2009 -0500
+++ b/debuggercdi/com.nokia.carbide.cpp.debug.kernelaware/src/com/nokia/carbide/cpp/debug/kernelaware/ui/SymbianOSView.java Wed Apr 01 14:49:26 2009 -0500
@@ -166,6 +166,10 @@
// Make this option static so that it's consistent across view sessions.
static boolean m_autoRefresh = true;
+ private TabFolder tabFolder;
+
+ private int refreshCount;
+
/*
* (non-Javadoc)
*
@@ -174,7 +178,7 @@
@Override
public void createPartControl(Composite parent) {
- final TabFolder tabFolder = new TabFolder(parent, SWT.NONE);
+ tabFolder = new TabFolder(parent, SWT.NONE);
tabFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DoAction_TabSelection(e.item);
@@ -535,6 +539,7 @@
}
listener.dataUpdated(session, status);
+ refreshCount++;
monitor.done();
@@ -734,7 +739,7 @@
Messages.getString("SymbianOSView.MessageTitle"), Messages.getString("SymbianOSView.MessagePrefix") + message); //$NON-NLS-1$ //$NON-NLS-2$
}
- private void DoAction_TabSelection(Widget item) {
+ public void DoAction_TabSelection(Widget item) {
if (item == null)
return;
@@ -800,7 +805,7 @@
* device.
*
*/
- private void DoAction_Refresh() {
+ public void DoAction_Refresh() {
if (m_currentSession == null)
return;
@@ -811,16 +816,20 @@
computeInput(m_currentSession, this, true);
}
- private void DoAction_ToggleAutoRefresh() {
- m_autoRefresh = !m_autoRefresh;
+ public void DoAction_ToggleAutoRefresh() {
+ setAutoRefresh(!m_autoRefresh);
}
- private void DoAction_CollapseAll() {
+ public void setAutoRefresh(boolean enabled) {
+ m_autoRefresh = enabled;
+ }
+
+ public void DoAction_CollapseAll() {
if (m_overviewTreeViewer != null)
m_overviewTreeViewer.collapseAll();
}
- private void DoAction_Debug() {
+ public void DoAction_Debug() {
/*
* Attach debugger to a process or thread.
*/
@@ -1256,4 +1265,20 @@
}
}
}
+
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (adapter.isInstance(this))
+ return this;
+ if (adapter.isInstance(tabFolder))
+ return tabFolder;
+ if (adapter.isInstance(m_currentViewer))
+ return m_currentViewer;
+
+ return super.getAdapter(adapter);
+ }
+
+ public int getRefreshCount() {
+ return refreshCount;
+ }
}