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 163941 Details for
Bug 308220
Test failures in EPartServiceTest, ESelectionServiceTest
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.
[patch]
Tests patch to reproduce the problem
bug308220-tests-patch-v1.txt (text/plain), 5.60 KB, created by
Remy Suen
on 2010-04-06 13:41:00 EDT
(
hide
)
Description:
Tests patch to reproduce the problem
Filename:
MIME Type:
Creator:
Remy Suen
Created:
2010-04-06 13:41:00 EDT
Size:
5.60 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.e4.ui.tests >Index: src/org/eclipse/e4/ui/tests/UIAllTests.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/UIAllTests.java,v >retrieving revision 1.14 >diff -u -r1.14 UIAllTests.java >--- src/org/eclipse/e4/ui/tests/UIAllTests.java 18 Jan 2010 20:58:24 -0000 1.14 >+++ src/org/eclipse/e4/ui/tests/UIAllTests.java 6 Apr 2010 17:37:35 -0000 >@@ -15,6 +15,7 @@ > import junit.framework.TestSuite; > > import org.eclipse.e4.ui.tests.application.Bug299755Test; >+import org.eclipse.e4.ui.tests.application.Bug308220Test; > import org.eclipse.e4.ui.tests.application.StartupTestSuite; > import org.eclipse.e4.ui.tests.reconciler.ModelReconcilerTestSuite; > import org.eclipse.e4.ui.tests.workbench.ContextTest; >@@ -39,6 +40,7 @@ > public UIAllTests() { > addTest(StartupTestSuite.suite()); > addTestSuite(Bug299755Test.class); >+ addTestSuite(Bug308220Test.class); > addTestSuite(PartRenderingEngineTests.class); > addTestSuite(MMenuItemTest.class); > addTestSuite(MPartTest.class); >Index: src/org/eclipse/e4/ui/tests/application/Bug308220Test.java >=================================================================== >RCS file: src/org/eclipse/e4/ui/tests/application/Bug308220Test.java >diff -N src/org/eclipse/e4/ui/tests/application/Bug308220Test.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/ui/tests/application/Bug308220Test.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,114 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.e4.ui.tests.application; >+ >+import java.lang.reflect.InvocationTargetException; >+ >+import javax.inject.Inject; >+import javax.inject.Named; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.e4.core.contexts.ContextChangeEvent; >+import org.eclipse.e4.core.contexts.ContextFunction; >+import org.eclipse.e4.core.contexts.ContextInjectionFactory; >+import org.eclipse.e4.core.contexts.EclipseContextFactory; >+import org.eclipse.e4.core.contexts.IContextConstants; >+import org.eclipse.e4.core.contexts.IEclipseContext; >+import org.eclipse.e4.core.contexts.IRunAndTrack; >+import org.eclipse.e4.core.di.annotations.Optional; >+import org.eclipse.e4.ui.services.IServiceConstants; >+ >+public class Bug308220Test extends TestCase { >+ >+ static class WindowService { >+ >+ @Inject >+ @Named(IServiceConstants.ACTIVE_PART) >+ @Optional >+ Object activePart; >+ } >+ >+ public void testBug308220() throws Exception { >+ IEclipseContext app = EclipseContextFactory.create(); >+ app.set(WindowService.class.getName(), new ContextFunction() { >+ @Override >+ public Object compute(IEclipseContext context, Object[] arguments) { >+ try { >+ return ContextInjectionFactory.make(WindowService.class, >+ context); >+ } catch (InvocationTargetException e) { >+ throw new RuntimeException(e); >+ } catch (InstantiationException e) { >+ throw new RuntimeException(e); >+ } >+ } >+ }); >+ // lookup function that goes down the context's active child chain >+ app.set(IServiceConstants.ACTIVE_PART, new ContextFunction() { >+ @Override >+ public Object compute(IEclipseContext context, Object[] arguments) { >+ IEclipseContext childContext = (IEclipseContext) context >+ .getLocal(IContextConstants.ACTIVE_CHILD); >+ if (childContext == null) { >+ return null; >+ } >+ >+ while (childContext != null) { >+ context = childContext; >+ childContext = (IEclipseContext) context >+ .getLocal(IContextConstants.ACTIVE_CHILD); >+ } >+ return context.getLocal(Object.class.getName()); >+ } >+ }); >+ >+ app.runAndTrack(new IRunAndTrack() { >+ public boolean notify(ContextChangeEvent event) { >+ // remove this line to pass the test >+ event.getContext().get(IServiceConstants.ACTIVE_PART); >+ return true; >+ } >+ }, null); >+ >+ // create two contexts >+ IEclipseContext windowA = EclipseContextFactory.create(app, null); >+ IEclipseContext windowB = EclipseContextFactory.create(app, null); >+ >+ Object o1 = new Object(); >+ Object o2 = new Object(); >+ >+ IEclipseContext part = EclipseContextFactory.create(windowA, null); >+ // set the active part as some object >+ part.set(Object.class.getName(), o1); >+ // construct the active chain >+ windowA.set(IContextConstants.ACTIVE_CHILD, part); >+ app.set(IContextConstants.ACTIVE_CHILD, windowA); >+ >+ WindowService windowServiceA = (WindowService) windowA >+ .get(WindowService.class.getName()); >+ WindowService windowServiceB = (WindowService) windowB >+ .get(WindowService.class.getName()); >+ >+ // windowA should have an active part, it was set earlier >+ assertEquals(o1, windowServiceA.activePart); >+ // windowB has no child contexts, this should be null >+ assertNull(windowServiceB.activePart); >+ >+ // change the active part >+ part.set(Object.class.getName(), o2); >+ >+ // windowA's active part should have changed >+ assertEquals(o2, windowServiceA.activePart); >+ // windowB should still have no active part >+ assertNull(windowServiceB.activePart); >+ } >+}
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 Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 308220
: 163941 |
163956