Sha256: 5b8b87e72c1b3576ef050d976835a10ae21745d9a0ae2c36f1e51e01ea8f6601

Contents?: true

Size: 1.68 KB

Versions: 6

Compression:

Stored size: 1.68 KB

Contents

describe UnderOs::UI::Wrap do

  describe 'with raw iOS ui instances' do
    def wrap_class_for(raw_class)
      raw = raw_class.alloc.initWithFrame([[0,0],[0,0]])
      UnderOs::UI::View.new(raw).class
    end

    it "should wrap correctly simple views" do
      wrap_class_for(UIView).should == UnderOs::UI::View
    end

    it "should wrap buttons correctly" do
      wrap_class_for(UIButton).should == UnderOs::UI::Button
    end

    it "should wrap labels correctly" do
      wrap_class_for(UILabel).should == UnderOs::UI::Label
    end

    it "should wrap images correctly" do
      wrap_class_for(UIImageView).should == UnderOs::UI::Image
    end

    it "should return the same wrapper for the same uiview all the time" do
      raw  = UIView.alloc.initWithFrame([[0,0],[0,0]])
      inst = UnderOs::UI::View.new(raw)

      UnderOs::UI::View.new(raw).should.be.same_as inst
      UnderOs::UI::View.new(raw).should.be.same_as inst
      UnderOs::UI::View.new(raw).should.be.same_as inst
    end
  end

  describe 'initialization' do
    before do
      @view = UnderOs::UI::View.new
    end

    it "should build a raw uiview object" do
      @view._.class.should == UIView
    end

    it "should register the raw view in the cache" do
      UnderOs::UI::View.new(@view._).should.be.same_as @view
    end
  end

  describe 'weird subclasses' do

    class WeirdView < UnderOs::UI::View
      attr_reader :a, :b, :c
      def initialize(a,b,c)
        super({})
        @a = a
        @b = b
        @c = c
      end
    end

    it "should anny arguments for the constructor" do
      view = WeirdView.new(1, 2, 3)
      view.a.should == 1
      view.b.should == 2
      view.c.should == 3
    end
  end

end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
under-os-ui-1.4.0 spec/under_os/ui/utils/wrap_spec.rb
under-os-1.3.0 spec/lib/under_os/ui/utils/wrap_spec.rb
under-os-1.2.1 spec/lib/under_os/ui/utils/wrap_spec.rb
under-os-1.2.0 spec/lib/under_os/ui/utils/wrap_spec.rb
under-os-1.1.0 spec/lib/under_os/ui/utils/wrap_spec.rb
under-os-1.0.0 spec/lib/under_os/ui/utils/wrap_spec.rb