Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 308220

Summary: Test failures in EPartServiceTest, ESelectionServiceTest
Product: [Eclipse Project] e4 Reporter: Remy Suen <remy.suen>
Component: UIAssignee: Project Inbox <e4.ui-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ob1.eclipse
Version: 1.0   
Target Milestone: 1.0 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Tests patch to reproduce the problem
none
Patch none

Description Remy Suen CLA 2010-04-06 11:23:32 EDT
EPartServiceTest
-testEvent_PartActivated2
-testEvent_PartDeactivated2
-testSwitchWindows

ESelectionServiceTest
-testThreePartSelection

If I rollback attachment 163896 [details], the problem goes away. It's quite possible the culprit is in the EPS/ESS implementations themselves. Will take a look.
Comment 1 Oleg Besedin CLA 2010-04-06 11:47:27 EDT
I've looked at one of the test failures - testEvent_PartActivated2() and it seems to be a problem with the expected test result.

What seems to happen, is that partServiceB activates a part which gets propagated to the parent context:

	parentContext.set(IContextConstants.ACTIVE_CHILD, curContext);

The partServiceA relies on the child of that context which has no active child set at this point, so the active part value gets propagated to the partServiceA.

Are partServiceA and partServiceB supposed to produce different results when asked what is the active part? (Which can be turned into a more interesting question, why would we have multiple part services in the same model.)
Comment 2 Remy Suen CLA 2010-04-06 11:56:27 EDT
(In reply to comment #1)
> The partServiceA relies on the child of that context which has no active child
> set at this point, so the active part value gets propagated to the
> partServiceA.

The partServiceB is activating parts that it doesn't know about (partA and partB are both in windowA). Technically speaking, the activate request from partServiceB should be a no-op.

> Are partServiceA and partServiceB supposed to produce different results when
> asked what is the active part?

Yes. The active part of windowA should not be the active part of windowB. Every workbench window has its own active part.
Comment 3 Remy Suen CLA 2010-04-06 11:59:53 EDT
(In reply to comment #2)
> The partServiceB is activating parts that it doesn't know about (partA and
> partB are both in windowA). Technically speaking, the activate request from
> partServiceB should be a no-op.

Correction! :/

Both parts are in windowB. Activating those parts should not cause part events in windowA because windowA does not know about those parts.
Comment 4 Remy Suen CLA 2010-04-06 13:41:00 EDT
Created attachment 163941 [details]
Tests patch to reproduce the problem

This test will reproduce the problem with pure context-related code.

It seems the RAT's invocation inadvertently causes window B to be injected. I would expect window B's part to always be computed from the context function (which should always be null because it has no active child context).
Comment 5 Remy Suen CLA 2010-04-06 13:48:02 EDT
(In reply to comment #4)
> It seems the RAT's invocation inadvertently causes window B to be injected. I
> would expect window B's part to always be computed from the context function
> (which should always be null because it has no active child context).

If I set new instances of the same context function to both windows then the propagation doesn't seem to happen. So in that regard scoping will be correct.
Comment 6 Oleg Besedin CLA 2010-04-06 15:27:09 EDT
Created attachment 163956 [details]
Patch

While working on e4 every now and then I feel like Alice in Wonderland. This is the fix for my earlier fix.
Comment 7 Oleg Besedin CLA 2010-04-06 15:29:43 EDT
Both patch and the test released to CVS Head. 

Remy, thank you for finding this and taking time to prepare the test case!