class TestActMonitor

class TestActMonitor < Test::Unit::TestCase

Public Instance Methods

nutest_many_monitors() click to toggle source
# File vendor/qwik/lib/qwik/act-monitor.rb, line 144
def nutest_many_monitors
  setup_monitor

  ts = []
  res = []
  max = 15

  (0..max).each {|i|
    ts[i] = Thread.new {
      res[i] = session('/test/1.monitor')  # Wait for update.
      ok_in([:p, 't3'], "//div[@class='section']", res[i])
    }
  }

  #sleep 0.1
  tres = session('/test/1.save?contents=t3')
  assert_text('Page is saved.', 'title', tres)

  (0..max).each {|i|
    ts[i].join     # Wait for the thread.
  }
end
setup_monitor() click to toggle source
# File vendor/qwik/lib/qwik/act-monitor.rb, line 85
def setup_monitor
  #Thread.abort_on_exception = true
  t_add_user
  page = @site.create_new
  page.store('*t')
end
test_act_monitor() click to toggle source
# File vendor/qwik/lib/qwik/act-monitor.rb, line 106
def test_act_monitor
  setup_monitor

  t = Thread.new {
    res = session('/test/1.monitor')       # Wait for update.
    ok_in([:p, 't2'], "//div[@class='section']", res)
  }

  tres = session('/test/1.save?contents=t2')
  ok_in(['Page is saved.'], 'title', tres)

  t.join    # Wait for the thread.
end
test_act_monitor_1st() click to toggle source
# File vendor/qwik/lib/qwik/act-monitor.rb, line 92
def test_act_monitor_1st
  setup_monitor

  t = Thread.new {
    tres = session('/test/1.save?contents=t2')
    ok_in(['Page is saved.'], 'title', tres)
  }

  res = session('/test/1.monitor')  # Wait for update.
  ok_in([:p, 't2'], "//div[@class='section']", res)

  t.join    # Wait for the thread.
end
test_several_monitors() click to toggle source
# File vendor/qwik/lib/qwik/act-monitor.rb, line 120
def test_several_monitors
  setup_monitor

  # FIXME: This test sometimes fails.
  t1 = Thread.new {
    t1res = session('/test/1.monitor')     # Wait for update.
    ok_in([:p, 't3'], "//div[@class='section']", t1res)
  }

  # FIXME: Sometimes fails.
  t2 = Thread.new {
    t2res = session('/test/1.monitor')     # Wait for update.
    ok_in([:p, 't3'], "//div[@class='section']", t2res)
  }

  #sleep 0.5
  #sleep 0.1
  tres = session('/test/1.save?contents=t3')
  ok_in(['Page is saved.'], 'title', tres)

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