Skip to content

Commit

Permalink
fix(android): scrollableview "views" property is wrongly empty before…
Browse files Browse the repository at this point in the history
… window open

Fixes TIMOB-28504
  • Loading branch information
jquick-axway authored and sgtcoolguy committed Jul 13, 2021
1 parent 535430c commit 9b30837
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ public ScrollableViewProxy()
defaultValues.put(TiC.PROPERTY_OVER_SCROLL_MODE, 0);
}

@Override
public void handleCreationDict(KrollDict properties)
{
super.handleCreationDict(properties);

if (properties.containsKey(TiC.PROPERTY_VIEWS)) {
setViews(properties.get(TiC.PROPERTY_VIEWS));
}
}

@Override
public TiUIView createView(Activity activity)
{
Expand Down
30 changes: 22 additions & 8 deletions tests/Resources/ti.ui.scrollableview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,10 @@ describe('Titanium.UI.ScrollableView', () => {
should(scrollableView.currentPage).eql(0);
});

// FIXME explicitly setting currentPage doesn't seem to update value on Android
it.androidBroken('can be assigned an Integer value', () => {
it('can be assigned an Integer value', () => {
scrollableView.views = [ Ti.UI.createView(), Ti.UI.createView() ];
scrollableView.currentPage = 1;
should(scrollableView.currentPage).eql(1); // Android gives 0
should(scrollableView.currentPage).eql(1);
});

it('has no accessors', () => {
Expand Down Expand Up @@ -207,24 +206,39 @@ describe('Titanium.UI.ScrollableView', () => {
});

describe('.views', () => {
beforeEach(() => {
scrollableView = Ti.UI.createScrollableView();
});

it('is an Array', () => {
scrollableView = Ti.UI.createScrollableView();
should(scrollableView).have.property('views').which.is.an.Array();
});

it('defaults to empty Array', () => {
scrollableView = Ti.UI.createScrollableView();
should(scrollableView.views).be.empty();
});

it('can be assigned an Array of Ti.UI.Views', () => {
it('assigned during creation', () => {
scrollableView = Ti.UI.createScrollableView({
views: [ Ti.UI.createView(), Ti.UI.createView(), Ti.UI.createView() ]
});
should(scrollableView.views.length).eql(3);
});

it('assigned after creation', () => {
scrollableView = Ti.UI.createScrollableView();
scrollableView.views = [ Ti.UI.createView(), Ti.UI.createView() ];
should(scrollableView.views.length).eql(2);
});

it('update after creation', () => {
scrollableView = Ti.UI.createScrollableView({
views: [ Ti.UI.createView(), Ti.UI.createView() ]
});
scrollableView.views = scrollableView.views.concat(Ti.UI.createView(), Ti.UI.createView());
should(scrollableView.views.length).eql(4);
});

it('has no accessors', () => {
scrollableView = Ti.UI.createScrollableView();
should(scrollableView).not.have.accessors('views');
});
});
Expand Down

0 comments on commit 9b30837

Please sign in to comment.