Skip to content

Commit

Permalink
fix(android): drawer events for rightView (#13619)
Browse files Browse the repository at this point in the history
* fix(android): drawer events for rightView

* add tests

* lint
  • Loading branch information
m1ga committed Oct 28, 2022
1 parent 34c8b9d commit b837cc2
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 4 deletions.
Expand Up @@ -301,6 +301,10 @@ private void initRight()
rightFrame.setLayoutParams(frameLayout);

layout.addView(rightFrame);

if (drawerToggle == null) {
initDrawerToggle();
}
}

public void setCenterView(TiViewProxy viewProxy)
Expand Down
74 changes: 70 additions & 4 deletions tests/Resources/ti.ui.android.drawerlayout.test.js
Expand Up @@ -106,9 +106,16 @@ describe.android('Titanium.UI.Android.DrawerLayout', () => {
});

it('.toolbar', finish => {
const window = Ti.UI.createWindow({ theme: 'Theme.Titanium.NoTitleBar' });
const toolbar = Ti.UI.createToolbar({ titleTextColor: 'red', backgroundColor: 'cyan' });
drawerLayout = Ti.UI.Android.createDrawerLayout({ toolbar: toolbar });
const window = Ti.UI.createWindow({
theme: 'Theme.Titanium.NoTitleBar'
});
const toolbar = Ti.UI.createToolbar({
titleTextColor: 'red',
backgroundColor: 'cyan'
});
drawerLayout = Ti.UI.Android.createDrawerLayout({
toolbar: toolbar
});
window.add(drawerLayout);
window.addEventListener('open', () => {
try {
Expand All @@ -135,7 +142,9 @@ describe.android('Titanium.UI.Android.DrawerLayout', () => {

// Test for theme with disabled default ActionBar
it('for Theme.Titanium.NoTitleBar', () => {
const window = Ti.UI.createWindow({ theme: 'Theme.Titanium.NoTitleBar' });
const window = Ti.UI.createWindow({
theme: 'Theme.Titanium.NoTitleBar'
});
drawerLayout = Titanium.UI.Android.createDrawerLayout();
window.add(drawerLayout);
should(drawerLayout.toolbarEnabled).be.true(); // default value
Expand All @@ -146,4 +155,61 @@ describe.android('Titanium.UI.Android.DrawerLayout', () => {
});
});
});

describe('events', () => {

let drawerWindow;
let centerView;
let menuView;

afterEach(() => {
drawerWindow = null;
centerView = null;
menuView = null;
});

beforeEach(() => {
drawerWindow = Ti.UI.createWindow();
centerView = Ti.UI.createView();
menuView = Ti.UI.createView({
backgroundColor: 'red'
});
});

it('check left open event', finish => {
const drawer = Ti.UI.Android.createDrawerLayout({
centerView: centerView,
leftView: menuView,
});
drawer.addEventListener('open', function (e) {
should(e.drawer).eql('left');
finish();
});
drawerWindow.add(drawer);
drawerWindow.open();
drawerWindow.addEventListener('open', function () {
setTimeout(function () {
drawer.toggleLeft();
}, 500);
});
});

it('check right open event', finish => {
const drawer = Ti.UI.Android.createDrawerLayout({
centerView: centerView,
rightView: menuView,
});
drawer.addEventListener('open', function (e) {
should(e.drawer).eql('right');
finish();
});
drawerWindow.add(drawer);
drawerWindow.addEventListener('open', function () {
setTimeout(function () {
drawer.toggleRight();
}, 500);
});
drawerWindow.open();
});
});
});

0 comments on commit b837cc2

Please sign in to comment.