how to click on action bar menu items in test app that having only apk using robotium - robotium

I am testing APK file. I dont have source code. I need to click on the action bar menu item
I have tried solo.clickonActionbaritems option and it did not work. Please help me. Many thanks!

I guess you want to click on Android Menu button:
Find your keycode here
solo.sendKey(KeyEvent.KEYCODE_MENU);
Also I highly recommend to use Hierarchy viewer in DDMS to find id of required button.
View requiredButton = getViewById(id.reqired_button_id);
solo.clickOnView(requiredButton);
// Method returns view
protected View getViewById(int id) {
View view = solo.getView(id);
assertNotNull("View is null", view);
assertTrue("View is not shown", view.isShown());
return view;
}
Also you can use clickOnText.

Related

Durandal view no more displayed if user click quickly on menus

I use Durandal 2.0 & Breeze in my SPA.
I have a sidebar menu for my drivers (Chauffeurs) where user can click on submenus (Récents, Disponibles, Indisponibles) for calling my view with different parameters. This will fill a koGrid with data. The data is fetched in the activate call and the binding of the koGrid is done in the compositionComplete.
Everything goes well most of the time. Things goes wrong when I click very quickly on submenus (calling the same view). Example: I click on 'Récents' and immediately (without waiting for the view to display) I click on 'Disponibles'.
I have the following for the activate:
var activate = function (filterParam) {
filter(filterParam);
pagedDataSource.getDataFunction = getData;
pagedDataSource.getPredicatesFunction = getPredicates;
return pagedDataSource.reload();
};
And I have the following code for the compositionComplete:
var compositionComplete = function (view) {
bindEventToList(view, '.kgCellText', gotoDetails);
$('#mySearchGrid').attr('data-bind', 'koGrid: gridOptions');
ko.applyBindings(vm, document.getElementById('mySearchGrid'));
};
When I trace the activity, I noted that if user click quickly on submenus, the activate does not have the time to finish and is called again (for the second click of the user) and the compositionComplete does not execute. Then after that, nothing more happened visually. It seems blocked.
Any idea how can I prevent this problem?
Thanks.
The migration to the latest Durandal version 2.0.1 fixed the problem.

Get the visibility status of a toolbar according to Customize perspective dialog in Eclipse

I'm working on a plug-in, which contributes to the toolbar. The toolbar is listed in the Customize perstpective dialog. When I uncheck the check-box, the toolbar disappears as expected. But when the toolbar is updated from my code (using the toolbar manager), it gets displayed again. I need to get somehow the visibility status from code in order to prevent the toolbar from beeing updated when disabled.
Do you anybody have any idea, where the Customize perspective dialog stores the visibility status of menus and toolbars and how to get it from code, please?
You can get information by item ID this way:
private static boolean isToolbarItemVisible(String id){
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
return !((WorkbenchPage) workbenchWindow.getActivePage()).getHiddenItems().contains((ModeledPageLayout.HIDDEN_TOOLBAR_PREFIX + id + ","));
}

How to show a Safari Extension popover programmatically

I'm trying to write a Safari extension that consists of a button on the main toolbar with a popover tied to it, and a contextual menu item. The basic feel is modeled after the feel of the 1Password extension.
One of the jobs of the popover is to allow a person to log in. I'm also conditionally changing the action of the contextual menu item, and if a who person isn't logged in clicks the menu item I would like to show the popover allowing them to log in, but I can't find a way to do this in the developer guides.
How do I "show" a popover?
If you only have one toolbar item and one popover (and never plan to add more), then it's just one line. Assuming you've already assigned the popover to the toolbar item in Extension Builder, you can just use:
safari.extension.toolbarItems[0].showPopover();
But if you have more than one popover and (potentially) more than one toolbar item, here's a generalized function to open a popover, specified by its identifier, under the specified toolbar item in the active browser window:
function showPopover(popoverId, toolbarItemId) {
var toolbarItem = safari.extension.toolbarItems.filter(function (tbi) {
return tbi.identifier == toolbarItemId && tbi.browserWindow == safari.application.activeBrowserWindow;
})[0];
var popover = safari.extension.popovers.filter(function (po) {
return po.identifier == popoverId;
})[0];
toolbarItem.popover = popover;
toolbarItem.showPopover();
}

Changing views on button click in Sencha Touch

I came across a situation in sencha touch where i need to change from one view to another on click of a button .
My view 1 is a dashboard which displays around 8 icons and on click of each icon different views are shown . So, i placed an home button in the header of those 8 different views and i am trying to get back to the dashboard which is not hapenning .Instead it is showing a blank screen and there was no error displayed in the console for me to check .
My code for changing the view on button click was :
{
xtype:'button',
cls:'clsHome',
text:'Home',
style: 'background:#4A4245;color:white;',
handler: function() {
console.log("Home Clicked");
var dashboardPanel = Ext.create('AppSupport.view.DashBoard');
Ext.Viewport.add(dashboardPanel);
//Ext.Viewport.setActiveItem(dashboardPanel,{type: 'slide', direction: 'left'});
}
}
Help me Guys ... Thanks in Advance ...!!!
You should try the Using Navigation View tutorial in sencha architect documentation... It gives a simple step by step guide for view navigation for an app. The navigation view also provides in built history support from sencha touch 2 onwards which also makes going back simple and easy
http://docs.sencha.com/architect/2/#!/guide/navigationview

Dynamic popup menu for all views

I need to provide a dynamic popup menu for all views. I can create a dynamic popup menu contributibution, but I must set the URI and register it for certain view. Now I'm trying to register the menu dynamically, when the user selects another view:
public class GlobalSelectionListener implements ISelectionListener {
HashSet<IWorkbenchPart> extended = new HashSet<IWorkbenchPart>();
#Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (!extended.contains(part)) {
IWorkbenchPartSite wps = part.getSite();
if (wps == null)
return;
//creates popup menu for this part
MenuManager mgr = new MenuManager();
mgr.add(new DynamicMenu()); //DynamicMenu extends ContributionItem
wps.registerContextMenu("identifier." + mgr.hashCode(), mgr, wps.getSelectionProvider());
extended.add(part);
System.out.println(part + " menu extended");
}
}
}
But this does not work. No one menu item appears in popup menu. I don't know, whether is it ever possible to do it this way. Is there any method to add popup menu for arbitrary view dynamically? It seems, that the registerContextMenu() method does something else.
The problem was not solved, nevertheless there is a workaround. It is possible to register the pop-up menu in plugin.xml file for all views and editors needed. Usualy the number of plugin usecases is limited. If you're writting a plugin, you know what you need the plugin for. Use the Spy plug-in (ALT+SHIFT+F1) to see the active menu contribution identifiers and register your contribution to the pop-up menu of all views and editors you need.