Is there any way with Calabash to Query ALL objects in a screen? (really all) - calabash

With Calabash, the Query("all *") gets about twice as much data as the query("*") alone does, but I still have data I cannot read without complex scroll logic.
Is there any good way to get a true 'All' data from a screen without scrolling?
For example, I have a screen with 12 containers each with 5-10 distinct pieces of data. I need to be able to read my containers to validate the data on the page.

query returns all visible views.
query("all *") disables the visibility heuristics and returns all views.
Even when using all, some part of the view rect must exist within the bounds of the screen.
without scrolling
If you are using Calabash iOS, you can try the scroll_to_* methods which are documented here:
http://calabashapi.xamarin.com/ios/Calabash/Cucumber/Core.html
scroll_to_mark is the most generic - I recommend starting with that method.

Related

How do you display rapidly updating data to the user in a win32 GUI app?

So im building a basic win32 GUI app and I have a vector of data that gets constantly updated through an external source via a port. Im interested in displaying that list of data to the user but im not sure the best approach to go about it without causing update flickering.
I originally had an edit box in which I build a string with the information and update the window. But it has proved troublesome as the amount of data grows since I cant scroll down to look at additional data. Any ideas?
My idea is no point of updating the visual control as the same speed you receive the data. Because even-though you update at the same speed the users cannot see that change at the speed of data receiving. Human eye does not see a change happening in speed as 1/8th of a second. So better to update the visual control in a controlled manner. Maybe using a timer.
Appending to the text of an edit control for each subsequent data point will lead to flickering as the whole control re-renders as the text has changed.
I'd advise one of the following options:
1) use a ListBox or ListView control; when you add another row item, it only re-draws the new/changed/scrolled item. https://learn.microsoft.com/en-us/windows/desktop/controls/create-a-simple-list-box and https://learn.microsoft.com/en-us/windows/desktop/controls/list-view-controls-overview
2) If you only want an always-scrolling list of data, consider just having a command-line application that writes to the standard output and saves you a lot of trouble - cout or printf your data.
You can also use EM_SETSEL and EM_SCROLLCARET to automatically scroll, but also check the position of the scroll bar before doing that. If not at the bottom, it means that the user wanted to pause, so you can scroll.
Also, you can have the scroll lock key checked in order whether to scroll or not, after all that is what it's name is supposed to do.

WXWidgets TextCtrl or RichTextCtrl

I'm using wxWidgets for a log window of a piece of software which runs for many hours. The log can accumulate 10,000's of entries. Does the community have a suggestion for how not to have the GUI thread choke for many seconds when updating a textctrl or richtextctrl with this many lines? I'm open to using either control type but richtext is preferable to I can highlight warnings or errors.
It's currently set to readonly, so undo, redo, paste, etc are not active. I'm currently freezing and thawing it before and after adding content.
In a test case, I add 10000 lines to the text control with a freeze and thaw before and after. This operation still takes over a minute. Are these text controls simply incapable of handling long content?
Assuming your display is like a log, where each "line" is it's own entry, try using the wxListCtrl in "virtual mode". Basically, you maintain the data in your own control (a vector, array, whatever works) and the control asks you for only the data that is currently visible.
Inherit wxListCtrl with your own class and implement OnGetItem. When a row is visible, your derived control will have this method called for each row (and each column if you implement multiple columns) and you provide it with the data for that row, accessed directly from your array (list, vector, whatever).
More information is available in the wxWidgets docs here: http://docs.wxwidgets.org/3.0/classwx_list_ctrl.html#a92370967f97215e6068326645ee76624
The suggestion to use wxListCtrl in #avariant answer is a good one, however a wxTextCtrl with wxTE_RICH style should still be capable of appending 10000 lines in well less than a minute if you freeze/thaw it before/after. I'd be curious to know if you can reproduce the problem in the text sample included with wxWidgets (which already has a menu item doing something like this) and, if so, which wxWidgets port do you use.

testing a component with complex angular components nested inside using PageObjects

Our Application has components which consume components with consume components of varying complexity. So i just want the input on the page, to validate when an object is set that the text is correct. The issue is that it is one of these subcomponents.
My colleague told me that there is 2 ways to do this, The first is to use Page Objects, and Chaining annotation to find it on my page, and then find the next id etc until my input is found. It requires me to look through another teams' Component Markup to narrow it down to the input i want to leverage. I dont believe I should have to go into another component definition, or a definition of a definition to get the appropriate chain to get this arbitrary input. It starts to create issues where if a lateral team creates changes unbeknownst to me, my PO will be broken.
The other option my friend asked was to use fixture.query to find the component. This would be as simple as:
fixture.query((el)=> el.attribute["id"] == "description",
(comp){
expect(comp.value, value);
});`
Using Query looks at the markup but then will automatically componentize it as the appropriate SubComponent. In this case, comp.value is the value stored in the HTML. So, if i did something like:
fixture.update((MainComponent comp) {
comp.myinput.value = new Foo();
});
Then I am setting and getting this programmatically, so i am a bit unsure if it properly would reflect what is on the screen.
Whats the best course of action? It seems PO would be better, but im not sure if there is a way around having to deep query for input boxes outside of the component i am testing.
Thanks
I don't think I have a definitive answer for you but I can tell you how we do it at Google. For pretty much any component we provide the page object alongside the component. This is twofold it is for testing that widget, and also so we can have this as a shareable resource for other tests.
For leaf widgets the page objects are a little less fleshed out and are really just there for the local test. For components that are shared heavily the page object is a bit more flushed out for reusability. Without this much of the API for the widget (html, css, etc) we would need to consider public and changes to them would be very hard (person responsible for making the public breaking change needs to fix all associated code.) With it we can have a contract to only support the page object API and html structure changes are not considered breaking changes. At times we have even gone so far as to have two page objects for a widget. One for the local test, and one to share. Sometimes the API you want to expose for a local test is much more than you want people to use themselves.
We can then compose these page objects into higher level page objects that represent the widget. Good page objects support a higher level of abstraction for that widget. For example a calendar widget would let you go to the next/previous month, get the current selected date, etc. rather than directly exposing the buttons/inputs that accomplish those actions.
We plan to expose these page objects for angular_components eventually, but we are currently working on how to expose these. Our internal package structure is different than what we have externally. We have many packages per individual widget (page_objects, examples, widget itself) and we need to reconcile this externally before we expose them.
Here is an example:
import 'package:pageloader/objects.dart';
import 'material_button_po.dart';
/// Webdriver page object for `material-yes-no-buttons` component.
#EnsureTag('material-yes-no-buttons')
class MaterialYesNoButtonsPO {
#ByClass('btn-yes')
#optional
MaterialButtonPO yesButton;
#ByClass('btn-no')
#optional
MaterialButtonPO noButton;
}

Howto determine the first and last row qt model/view

I'm building an filebrowser based upon the QAbstractListModel and QListView.
As you know what is displayed can change, by making the window bigger, or by scrolling.
How can I determine the first and the last entry (or index) actually displayed. Do I have to program that myself?
Added later:
see for full description:
http://qt-project.org/forums/viewthread/26497/
Thanks in advance,
Stef Bon
Voorburg
the Netherlands
The reason provided in the comments is not adequate; the model is supposed to call beginInsertRows/endInsertRows at any time, even if the range where you are inserting items is not currently visible in the view. There are multiple reasons for that (proxy models, QPersistentModelIndex instances, selection handling, QAbstractItemView's internal housekeeping, caching of already rendered items etc).
The MVC API in Qt is designed so that the model is not supposed to know about what the view is currently showing. The contracts expressed in the QAbstractItemModel specify that the model "just" has to keep the rest of the world updated by calling the protected methods (which emit the rowsInserted etc signals, among other things). If you ever find yourself in a situation where you start thinking "hey, if only I knew how this model was displayed in the attached view", the correct thing is to make sure you are using the existing API effectively. As an example, a very common problem is that the programmer finds out that their model's data() method is called too often, for each item in a list, for example. The typical reason for this is that the corresponding QListView needs to know how much space to reserve for each item so that the scrollbar size can be determined. A correct way for this is to either return usable data for the SizeHintRole, or set the view's uniformRowSizes to true.

Refresh text shown in a GTK+ widget?

Being resonably new to using GTK+, im not fully aware of all its functionality.
Basically, I have a GtkTreeView widget that has 4 Columns. I need to update the text displayed in the 4 columns every couple of seconds, but im not aware how to do this in GTK+.
I'm aware that I could flush the data using gtk_tree_store_clear, but I'm not sure how to repopulate the columns and have the top level window refresh to show this new data?
You need to get a GtkTreeIter to the proper row, then use the appropriate (model-specific) setter to change the data.
For instance gtk_list_store_set() for the GtkListStore model.
There is no need to clear the entire model if you just want to change some of the data, that is very wasteful and slow.
If you really need to change all the data, then sure, clear it.
You don't have to worry about getting the display to refresh; the view listens to events from the model, and automatically knows to refresh when the model changes.
UPDATE:
When changing the data (as described in commment), you don't need to "flush" the old data. The model owns the data, and knows how to keep track of the memory used. You just use the above-mentioned gtk_list_store_set() call as necessary to put the new desired data in the model. You can do this as often as necessary, and an update frequency of once every few seconds should be no problem at all.
Of course, in such a case, to keep your application (which I assume is single-threaded, for simplicity) responsive, you must have a way to asynchronously trigger an update, perhaps using a timer. Have a look at glib's g_timeout_add() function to learn how to add a simple global timer.