summaryrefslogtreecommitdiffstats
path: root/spec/ecore_spec.rb
blob: d027ab6592bfae91d086e3a3e7f08a6cb4e2f118 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#! /usr/bin/env ruby
# -*- coding: UTF-8 -*-
#
require 'e17/ecore'
#
describe E17::ECORE do
    #
    include E17
    #
    it "should init" do
        ECORE.init.should eql 1
        ECORE.init.should eql 2
        ECORE.init.should eql 3
    end
    #
    it "should shutdown" do
        ECORE.shutdown.should eql 2
        ECORE.shutdown.should eql 1
        ECORE.shutdown.should eql 0
    end
    #
    it "should run a single iteration of the mainloop" do
        ECORE.init
        ECORE.main_loop_iterate
        ECORE.shutdown
    end
    #
    it 'should write and read data from pipe' do
        ECORE.init
        cb = Proc.new do |data,buffer,bytes|
            data.read_string.should eql 'none'
            buffer.read_string.should eql 'hello world'
            bytes.should eql 12
        end
        data = FFI::MemoryPointer.from_string("none")
        pipe = ECORE.pipe_add cb, data
        buffer = FFI::MemoryPointer.new(:string,128)
        buffer.write_string 'hello world'
        ECORE.pipe_write pipe, buffer, 12
        ECORE.main_loop_iterate
        ECORE.pipe_read_close pipe
        ECORE.pipe_write_close pipe
        ECORE.pipe_del pipe
        ECORE.shutdown
    end
end