class TestActEvent

Public Instance Methods

setup_event() click to toggle source
# File vendor/qwik/lib/qwik/act-event.rb, line 119
def setup_event
  Thread.abort_on_exception = true
  t_add_user
  page = @site.create_new
  page.store('*t')
end
test_event_1() click to toggle source
# File vendor/qwik/lib/qwik/act-event.rb, line 126
def test_event_1
  setup_event
  t = Thread.new {
    tres = session('/test/1.save?contents=t2')
    ok_in(['Page is saved.'], 'title', tres)
  }
  res = session('/test/1.event')    # Wait for update.
  #ok_eq(",0,user@e.com,1,save,save\n", res.body)
  t.join    # Wait for the thread.
end
test_event_2() click to toggle source
# File vendor/qwik/lib/qwik/act-event.rb, line 137
def test_event_2
  setup_event
  t = Thread.new {
    res = session('/test/1.event') # Wait for update.
    #ok_eq(",0,user@e.com,1,save,save\n", res.body)
  }
  tres = session('/test/1.save?contents=t2')
  ok_in(['Page is saved.'], 'title', tres)
  t.join    # Wait for the thread.
end
test_event_3_several_watchers() click to toggle source
# File vendor/qwik/lib/qwik/act-event.rb, line 148
def test_event_3_several_watchers
  setup_event
  t1 = Thread.new {
    t1res = session('/test/1.event')       # Wait for update.
    #ok_eq(",0,user@e.com,1,save,save\n", t1res.body)
  }
  t2 = Thread.new {
    t2res = session('/test/1.event')       # Wait for update.
    #ok_eq(",0,user@e.com,1,save,save\n", t2res.body)
  }
  tres = session('/test/1.save?contents=t2')
  ok_in(['Page is saved.'], 'title', tres)
  t1.join   # Wait for the thread.
  t2.join   # Wait for the thread.
end
test_event_4_many_watchers() click to toggle source
# File vendor/qwik/lib/qwik/act-event.rb, line 164
def test_event_4_many_watchers
  setup_event
  ts = []
  res = []
  #max = 20
  max = 5
  (0..max).each {|i|
    ts[i] = Thread.new {
      res[i] = session('/test/1.event')    # Wait for update.
      str = res[i].body
      if !(str == ",0,user@e.com,1,save,save\n" ||
           str == ",max_exceed\n" || str == ",disconnect\n")
        #ok_eq('', str)    # error
      end
    }
  }
  tres = session('/test/1.save?contents=t3')
  ok_in(['Page is saved.'], 'title', tres)
  (0..max).each {|i|
    ts[i].join     # Wait for the thread.
  }
end