Sha256: f997545b5b81386e35918a1b9061bc4530d20b7a06ab91ef2b898917f5047d35

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

# mock library for testing the IE controller
require 'watir'

class FakeFrame
    def length
        return 0
    end
end

class FakeAll
    def initialize(doc)
        @doc = doc
    end
    def tags(tag)
        @doc.links
    end
end


class FakeDoc
    
    attr_accessor :links, :all
    
    def initialize()
        @links = ""
        @all = FakeAll.new(self)
    end
    
    def frames
        return FakeFrame.new()
    end
    
    def readyState
        return "complete"
    end
    
    def addLink(value)
        if @links.nil?
            @links = value
        else
            @links << value
        end
    end
    
    def url
        return "file://fake"
    end
    
end

class StubExplorer
    
    attr_accessor :timeToWait
    
    def initialize()
        @timeToWait = 1
        @visible = $HIDE_IE
        @document = FakeDoc.new()
    end
    
    def document
        return @document
    end
    
    def busy ()
        sleep @timeToWait
        return FALSE
    end
    
    def readyState
        return 4
    end
    
    def visible=(value)
    end
    
end

class TestIE < Watir::IE
    
    def create_browser_window
        @ie = StubExplorer.new()
    end
    
    def addLink(link)
        @ie.document.addLink(link)
    end
    
    def setTimeToWait(time = 1)
        @ie.timeToWait = time
    end
    
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
watir-1.4.1 unittests/ie_mock.rb