mirror of
https://github.com/zhigang1992/rmq.git
synced 2026-04-29 13:15:36 +08:00
Merge pull request #186 from squidpunch/da-tests
Adds tests for UIPageControl; fixes incorrect spelling in test stylesheets
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
class SyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
attr_accessor :prev_view, :prev_frame
|
||||
|
||||
def my_style(st)
|
||||
@@ -141,7 +141,7 @@ end
|
||||
describe 'ui_view_styler' do
|
||||
before do
|
||||
@vc = UIViewController.alloc.init
|
||||
@vc.rmq.stylesheet = SyleSheetForUIViewStylerTests
|
||||
@vc.rmq.stylesheet = StyleSheetForUIViewStylerTests
|
||||
@view_klass = UIView
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class SyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
|
||||
def ui_button_kitchen_sink(st)
|
||||
st.text = 'foo'
|
||||
@@ -15,7 +15,7 @@ end
|
||||
describe 'stylers/ui_button' do
|
||||
before do
|
||||
@vc = UIViewController.alloc.init
|
||||
@vc.rmq.stylesheet = SyleSheetForUIViewStylerTests
|
||||
@vc.rmq.stylesheet = StyleSheetForUIViewStylerTests
|
||||
@view_klass = UIButton
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class SyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
|
||||
def ui_control_kitchen_sink(st)
|
||||
st.content_vertical_alignment = UIControlContentVerticalAlignmentFill
|
||||
@@ -12,7 +12,7 @@ end
|
||||
describe 'stylers/control' do
|
||||
before do
|
||||
@vc = UIViewController.alloc.init
|
||||
@vc.rmq.stylesheet = SyleSheetForUIViewStylerTests
|
||||
@vc.rmq.stylesheet = StyleSheetForUIViewStylerTests
|
||||
@view_klass = UIControl
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class SyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
|
||||
def u_image_view_kitchen_sink(st)
|
||||
st.image = image.resource('logo')
|
||||
@@ -9,7 +9,7 @@ end
|
||||
describe 'stylers/ui_image_view' do
|
||||
before do
|
||||
@vc = UIViewController.alloc.init
|
||||
@vc.rmq.stylesheet = SyleSheetForUIViewStylerTests
|
||||
@vc.rmq.stylesheet = StyleSheetForUIViewStylerTests
|
||||
@view_klass = UIImageView
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class SyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
|
||||
def ui_label_kitchen_sink(st)
|
||||
st.text = 'rmq is awesome'
|
||||
@@ -29,7 +29,7 @@ end
|
||||
describe 'stylers/ui_label' do
|
||||
before do
|
||||
@vc = UIViewController.alloc.init
|
||||
@vc.rmq.stylesheet = SyleSheetForUIViewStylerTests
|
||||
@vc.rmq.stylesheet = StyleSheetForUIViewStylerTests
|
||||
@view_klass = UILabel
|
||||
end
|
||||
|
||||
|
||||
36
spec/stylers/ui_page_control_styler_spec.rb
Normal file
36
spec/stylers/ui_page_control_styler_spec.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
def ui_page_control_kitchen_sink(st)
|
||||
st.number_of_pages = 4
|
||||
st.current_page = 2
|
||||
st.page_indicator_tint_color = color.green
|
||||
st.current_page_indicator_tint_color = color.red
|
||||
end
|
||||
end
|
||||
|
||||
describe 'stylers/ui_page_control_styler' do
|
||||
before do
|
||||
@vc = UIViewController.alloc.init
|
||||
@vc.rmq.stylesheet = StyleSheetForUIViewStylerTests
|
||||
@view_klass = UIPageControl
|
||||
end
|
||||
|
||||
behaves_like "styler"
|
||||
|
||||
it 'should apply a style with every UIPageControl wrapper method' do
|
||||
view = @vc.rmq.append!(@view_klass, :ui_page_control_kitchen_sink)
|
||||
|
||||
view.tap do |v|
|
||||
v.numberOfPages.should.equal(4)
|
||||
v.currentPage.should.equal(2)
|
||||
v.pageIndicatorTintColor.should.equal(rmq.color.green)
|
||||
v.currentPageIndicatorTintColor.should.equal(rmq.color.red)
|
||||
end
|
||||
|
||||
rmq(view).style do |st|
|
||||
st.number_of_pages.should.equal(4)
|
||||
st.current_page.should.equal(2)
|
||||
st.page_indicator_tint_color.should.equal(rmq.color.green)
|
||||
st.current_page_indicator_tint_color.should.equal(rmq.color.red)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
class SyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
def ui_progress_view_tints(st)
|
||||
st.progress_tint_color = UIColor.redColor
|
||||
st.track_tint_color = UIColor.blueColor
|
||||
@@ -15,7 +15,7 @@ end
|
||||
describe 'stylers/ui_progress_view' do
|
||||
before do
|
||||
@vc = UIViewController.alloc.init
|
||||
@vc.rmq.stylesheet = SyleSheetForUIViewStylerTests
|
||||
@vc.rmq.stylesheet = StyleSheetForUIViewStylerTests
|
||||
@view_klass = UIProgressView.alloc.initWithProgressViewStyle(UIProgressViewStyleDefault)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class SyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
|
||||
def ui_scroll_view_kitchen_sink(st)
|
||||
st.paging = st.paging
|
||||
@@ -26,7 +26,7 @@ end
|
||||
describe 'stylers/ui_scroll_view' do
|
||||
before do
|
||||
@vc = UIViewController.alloc.init
|
||||
@vc.rmq.stylesheet = SyleSheetForUIViewStylerTests
|
||||
@vc.rmq.stylesheet = StyleSheetForUIViewStylerTests
|
||||
@view_klass = UIScrollView
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class SyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
|
||||
def ui_switch_kitchen_sink(st)
|
||||
st.on = st.on
|
||||
@@ -10,7 +10,7 @@ end
|
||||
describe 'stylers/ui_switch' do
|
||||
before do
|
||||
@vc = UIViewController.alloc.init
|
||||
@vc.rmq.stylesheet = SyleSheetForUIViewStylerTests
|
||||
@vc.rmq.stylesheet = StyleSheetForUIViewStylerTests
|
||||
@view_klass = UISwitch
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class SyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
|
||||
def ui_table_view_cell_kitchen_sink(st)
|
||||
st.text_color = rmq.color.red
|
||||
@@ -12,7 +12,7 @@ end
|
||||
describe 'stylers/ui_table_view_cell' do
|
||||
before do
|
||||
@vc = UIViewController.alloc.init
|
||||
@vc.rmq.stylesheet = SyleSheetForUIViewStylerTests
|
||||
@vc.rmq.stylesheet = StyleSheetForUIViewStylerTests
|
||||
@view_klass = UITableViewCell
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class SyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
|
||||
def ui_table_view_kitchen_sink(st)
|
||||
st.separator_style = st.separator_style
|
||||
@@ -19,7 +19,7 @@ end
|
||||
describe 'stylers/ui_table_view' do
|
||||
before do
|
||||
@vc = UIViewController.alloc.init
|
||||
@vc.rmq.stylesheet = SyleSheetForUIViewStylerTests
|
||||
@vc.rmq.stylesheet = StyleSheetForUIViewStylerTests
|
||||
@view_klass = UITableView
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
describe 'stylers/ui_text_field' do
|
||||
class SyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
def ui_text_field_kitchen_sink(st)
|
||||
st.text = 'foo'
|
||||
st.color = color.red
|
||||
@@ -45,7 +45,7 @@ describe 'stylers/ui_text_field' do
|
||||
|
||||
before do
|
||||
@vc = UIViewController.new
|
||||
@vc.rmq.stylesheet = SyleSheetForUIViewStylerTests
|
||||
@vc.rmq.stylesheet = StyleSheetForUIViewStylerTests
|
||||
@view_klass = UITextField
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
describe 'stylers/ui_text_view' do
|
||||
class SyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
class StyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
||||
def ui_text_view_kitchen_sink(st)
|
||||
st.text = 'foo'
|
||||
st.color = color.red
|
||||
@@ -22,7 +22,7 @@ describe 'stylers/ui_text_view' do
|
||||
|
||||
before do
|
||||
@vc = UIViewController.alloc.init
|
||||
@vc.rmq.stylesheet = SyleSheetForUIViewStylerTests
|
||||
@vc.rmq.stylesheet = StyleSheetForUIViewStylerTests
|
||||
@view_klass = UITextView
|
||||
end
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ describe 'subviews' do
|
||||
end
|
||||
|
||||
it 'should append view and assign style_name' do
|
||||
@vc.rmq.stylesheet = SyleSheetForSubviewsTests
|
||||
@vc.rmq.stylesheet = StyleSheetForSubviewsTests
|
||||
view = @vc.rmq.append(UIButton, :my_style).get
|
||||
view2 = @vc.rmq.append(UIButton).get
|
||||
view.rmq_data.style_name.should == :my_style
|
||||
@@ -57,7 +57,7 @@ describe 'subviews' do
|
||||
end
|
||||
|
||||
it 'should unshift a view and apply a style' do
|
||||
@vc.rmq.stylesheet = SyleSheetForSubviewsTests
|
||||
@vc.rmq.stylesheet = StyleSheetForSubviewsTests
|
||||
view = @vc.rmq.unshift(UIView, :my_style).get
|
||||
@vc.view.subviews[0].should == view
|
||||
view.rmq_data.style_name.should == :my_style
|
||||
@@ -81,7 +81,7 @@ describe 'subviews' do
|
||||
end
|
||||
|
||||
it 'should add a subview at a specific index and apply a style' do
|
||||
@vc.rmq.stylesheet = SyleSheetForSubviewsTests
|
||||
@vc.rmq.stylesheet = StyleSheetForSubviewsTests
|
||||
view = @vc.rmq.append(UIView).get
|
||||
view2 = @vc.rmq.append(UIView).get
|
||||
view3 = @vc.rmq.append(UIView).get
|
||||
@@ -101,7 +101,7 @@ describe 'subviews' do
|
||||
end
|
||||
|
||||
it 'should add a subview below another view and apply a style' do
|
||||
@vc.rmq.stylesheet = SyleSheetForSubviewsTests
|
||||
@vc.rmq.stylesheet = StyleSheetForSubviewsTests
|
||||
view = @vc.rmq.append(UIView).get
|
||||
view2 = @vc.rmq.append(UIView).get
|
||||
view4 = @vc.rmq.insert(UIView, style: :my_style, below_view: view2).tag(:view4).get
|
||||
@@ -149,14 +149,14 @@ describe 'subviews' do
|
||||
end
|
||||
|
||||
it 'should allow you to create a view with a style, and it to use the stylesheet of view_controller that created it' do
|
||||
@vc.rmq.stylesheet = SyleSheetForSubviewsTests
|
||||
@vc.rmq.stylesheet = StyleSheetForSubviewsTests
|
||||
test_view = @vc.rmq.create(UILabel, :create_view_style).get
|
||||
test_view.backgroundColor.should == RubyMotionQuery::Color.blue
|
||||
end
|
||||
|
||||
it 'should allow you to create a view outside any view tree, then append subviews and those should use the stylesheet from the rmq that created the parent view' do
|
||||
q = @vc.rmq
|
||||
q.stylesheet = SyleSheetForSubviewsTests
|
||||
q.stylesheet = StyleSheetForSubviewsTests
|
||||
test_view_wrapped = q.create(SubviewTestView)
|
||||
test_view = test_view_wrapped.get
|
||||
|
||||
@@ -218,14 +218,14 @@ describe 'subviews' do
|
||||
|
||||
it 'should allow you to build an existing view with a style, and it to use the stylesheet of view_controller that created it' do
|
||||
my_view = UILabel.alloc.initWithFrame(CGRectZero)
|
||||
@vc.rmq.stylesheet = SyleSheetForSubviewsTests
|
||||
@vc.rmq.stylesheet = StyleSheetForSubviewsTests
|
||||
test_view = @vc.rmq.build(my_view, :create_view_style).get
|
||||
test_view.backgroundColor.should == RubyMotionQuery::Color.blue
|
||||
end
|
||||
|
||||
it 'should allow you to build a view outside any view tree, then append subviews and those should use the stylesheet from the rmq that created the parent view' do
|
||||
q = @vc.rmq
|
||||
q.stylesheet = SyleSheetForSubviewsTests
|
||||
q.stylesheet = StyleSheetForSubviewsTests
|
||||
my_view = SubviewTestView.alloc.initWithFrame(CGRectZero)
|
||||
test_view_wrapped = q.build(my_view)
|
||||
test_view = test_view_wrapped.get
|
||||
@@ -276,7 +276,7 @@ describe 'subviews' do
|
||||
end
|
||||
end
|
||||
|
||||
class SyleSheetForSubviewsTests < RubyMotionQuery::Stylesheet
|
||||
class StyleSheetForSubviewsTests < RubyMotionQuery::Stylesheet
|
||||
def my_style(st)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user