Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 375356 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/rwt/internal/lifecycle/SimpleLifeCycle.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2011 EclipseSource and others.
2
 * Copyright (c) 2011, 2012 EclipseSource and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 93-99 Link Here
93
          }
93
          }
94
        } );
94
        } );
95
      }
95
      }
96
      shutdownCallback.run();
96
      FakeContextUtil.runNonUIThreadWithFakeContext( display, shutdownCallback );
97
    }
97
    }
98
98
99
    public void processShutdown() {
99
    public void processShutdown() {
(-)src/org/eclipse/rwt/internal/lifecycle/SimpleLifeCycle_Test.java (+33 lines)
Lines 19-30 Link Here
19
import org.eclipse.rap.rwt.testfixture.*;
19
import org.eclipse.rap.rwt.testfixture.*;
20
import org.eclipse.rap.rwt.testfixture.internal.LoggingPhaseListener;
20
import org.eclipse.rap.rwt.testfixture.internal.LoggingPhaseListener;
21
import org.eclipse.rap.rwt.testfixture.internal.LoggingPhaseListener.PhaseEventInfo;
21
import org.eclipse.rap.rwt.testfixture.internal.LoggingPhaseListener.PhaseEventInfo;
22
import org.eclipse.rwt.RWT;
22
import org.eclipse.rwt.internal.application.ApplicationContextUtil;
23
import org.eclipse.rwt.internal.application.ApplicationContextUtil;
23
import org.eclipse.rwt.internal.application.RWTFactory;
24
import org.eclipse.rwt.internal.application.RWTFactory;
24
import org.eclipse.rwt.internal.service.ContextProvider;
25
import org.eclipse.rwt.internal.service.ContextProvider;
25
import org.eclipse.rwt.internal.service.RequestParams;
26
import org.eclipse.rwt.internal.service.RequestParams;
27
import org.eclipse.rwt.internal.service.SessionStoreImpl;
26
import org.eclipse.rwt.lifecycle.*;
28
import org.eclipse.rwt.lifecycle.*;
27
import org.eclipse.rwt.service.ISessionStore;
29
import org.eclipse.rwt.service.ISessionStore;
30
import org.eclipse.rwt.service.SessionStoreEvent;
31
import org.eclipse.rwt.service.SessionStoreListener;
28
import org.eclipse.swt.widgets.Display;
32
import org.eclipse.swt.widgets.Display;
29
33
30
34
Lines 228-233 Link Here
228
    }
232
    }
229
  }
233
  }
230
234
235
  public void testContextOnShutdownFromBackgroundThread() throws Exception {
236
    final boolean[] log = new boolean[ 1 ];
237
    // Activate SimpleLifeCycle
238
    RWTFactory.getLifeCycleFactory().deactivate();
239
    RWTFactory.getLifeCycleFactory().activate();
240
    registerEntryPoint( TestEntryPoint.class );
241
    final SessionStoreImpl sessionStore = ( SessionStoreImpl )RWT.getSessionStore();
242
    sessionStore.addSessionStoreListener( new SessionStoreListener() {
243
      public void beforeDestroy( SessionStoreEvent event ) {
244
        log[ 0 ] = ContextProvider.hasContext();
245
      }
246
    } );
247
    // Initialize shutdown adapter
248
    ( ( LifeCycle )RWT.getLifeCycle() ).execute();
249
250
    Thread thread = new Thread( new Runnable() {
251
      public void run() {
252
        sessionStore.getShutdownAdapter().interceptShutdown();
253
        // Prevents NPE in tearDown
254
        sessionStore.setShutdownAdapter( null );
255
      }
256
    } );
257
    thread.setDaemon( true );
258
    thread.start();
259
    thread.join();
260
261
    assertTrue( log[ 0 ] );
262
  }
263
231
  private void assertBeforePhaseEvent( PhaseEventInfo beforePrepareUIRoot, PhaseId phaseId ) {
264
  private void assertBeforePhaseEvent( PhaseEventInfo beforePrepareUIRoot, PhaseId phaseId ) {
232
    assertTrue( beforePrepareUIRoot.before );
265
    assertTrue( beforePrepareUIRoot.before );
233
    assertEquals( phaseId, beforePrepareUIRoot.phaseId );
266
    assertEquals( phaseId, beforePrepareUIRoot.phaseId );

Return to bug 375356