class CheckEvent

Public Instance Methods

test_1() click to toggle source

colinux:9190/HelloQwik/ActMonitor.html

# File vendor/qwik/lib/qwik/check-event.rb, line 34
def test_1
  return if $0 != __FILE__          # Only for unit test.

  server = setup_event

  str = get_path('1.html')
  ok_in(['t'], '//title', str)
  ok_in([:p, 'p'], "//div[@class='section']", str)

  t = Thread.new {
    sleep 0.1
    str = get_path("1.save?contents=*t2%0Ap2")     # Save to the page.
    ok_in(['Page is saved.'], '//title', str)
    ok_eq("*t2\np2", read_page('1'))
  }

  str = get_path('1.event')         # Wait for update.
  #ok_eq(",0,user@e.com,1,save,save\n", str)
  #ok_in([:p, 'p2'], "//div[@class='section']", str)

  t.join    # Wait for the thread.

  teardown_server(server)
end
test_2() click to toggle source
# File vendor/qwik/lib/qwik/check-event.rb, line 59
def test_2
  return if $0 != __FILE__          # Only for unit test.

  server = setup_event

  str = get_path('1.html')
  ok_in(['t'], '//title', str)
  ok_in([:p, 'p'], "//div[@class='section']", str)

  t = Thread.new {
    str = get_path('1.event')              # Wait for update.
    ok_eq(",0,user@e.com,1,save,save\n", str)
  }

  sleep 0.1
  str = get_path("1.save?contents=*t2%0Ap2")        # Save to the page.
  ok_in(['Page is saved.'], '//title', str)
  ok_eq("*t2\np2", read_page('1'))

  t.join    # Wait for the thread.

  teardown_server(server)
end
test_3() click to toggle source
# File vendor/qwik/lib/qwik/check-event.rb, line 83
def test_3
  return if $0 != __FILE__          # Only for unit test.

  server = setup_event

  str = get_path('1.html')
  ok_in(['t'], '//title', str)
  ok_in([:p, 'p'], "//div[@class='section']", str)

  t1 = Thread.new {
    str1 = get_path('1.event')     # Wait for update.
    ok_eq(",0,user@e.com,1,save,save\n", str1)
  }
  t2 = Thread.new {
    str2 = get_path('1.event')     # Wait for update.
    ok_eq(",0,user@e.com,1,save,save\n", str2)
  }

  sleep 0.1
  str = get_path("1.save?contents=*t2%0Ap2")        # Save to the page.
  ok_in(['Page is saved.'], '//title', str)
  ok_eq("*t2\np2", read_page('1'))

  t1.join   # Wait for the thread.
  t2.join   # Wait for the thread.

  teardown_server(server)
end