blob: a372849cf56f6e0a572ddeea9568681aa8333112 [file] [log] [blame]
Roman Elizarova198bad2017-02-10 13:30:38 +03001/*
2 * Copyright 2016-2017 JetBrains s.r.o.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package kotlinx.coroutines.experimental.swing
18
Roman Elizarovffc61ae2017-10-26 19:29:52 +030019import kotlinx.coroutines.experimental.*
Roman Elizarov45181042017-07-20 20:37:51 +030020import org.junit.Before
Roman Elizarova198bad2017-02-10 13:30:38 +030021import org.junit.Test
22import javax.swing.SwingUtilities
23
24class SwingTest : TestBase() {
Roman Elizarov45181042017-07-20 20:37:51 +030025 @Before
26 fun setup() {
27 ignoreLostThreads("AWT-EventQueue-")
28 }
29
Roman Elizarova198bad2017-02-10 13:30:38 +030030 @Test
31 fun testDelay() = runBlocking {
32 expect(1)
33 SwingUtilities.invokeLater { expect(2) }
34 val job = launch(Swing) {
35 check(SwingUtilities.isEventDispatchThread())
36 expect(3)
37 SwingUtilities.invokeLater { expect(4) }
38 delay(100)
39 check(SwingUtilities.isEventDispatchThread())
40 expect(5)
41 }
42 job.join()
43 finish(6)
44 }
45}