Espresso - How to match ActionBar visibility? - android-actionbar

Im trying to do a Espresso test for checking if actionbar is hidden/shown, but I cant seem to figure out how to match it with Espresso.onView(...). Afaik it doesnt have a id, right?
Thanks a lot

The action bar view has an ID but it's not exposed. We can get it with getIdentifier:
Resources resources = getInstrumentation().getTargetContext().getResources();
int actionBarId = resources.getIdentifier("action_bar_container", "id", "android");
onView(withId(actionBarId)).check(matches(isDisplayed()));
Code adapted from this related answer. I think this will work but I haven't tested it.

Related

Regex in add_rewrite_rule for wordpress for year and episode name

I think this is my last problem to solve before everything clicks into place:
I have a homepage with a custom plugin that sends some data to another page, I am building a theme for this website that works with the plugin.
So in the theme functions.php I have added a
function myvar($vars){
$vars[] = 'ep_year';
$vars[] = 'ep_name';
return $vars;
}
add_filter('query_vars','myvar');
works a charm, I can send those values over to a custom page with a custom template assigned.
This has a permalink as follows:
http://ngofwp.local/episode/
and when I send the data over it looks like so:
http://ngofwp.local/episode/?ep_year=2011&ep_name=silly_donkey
I know I have to use an add_rewrite_rule so I've started coding that as follows:
function custom_rewrite_rule()
{
add_rewrite_rule('^episode/([^/]*)/([^/]*)/([^/]*)?','ep_year=$matches[1]&ep_name=$matches[2]','top');
}
add_action('init', 'custom_rewrite_rule');
(this is pasted from an example I found)
But now for the life of me I have no clue about the formulae to get it to work. I have read the regex rules but not sure
What I'd like it to look like is this:
http://ngofwp.local/episode/2011/silly_donkey
The
http://ngofwp.local/episode/
is given by wordpress's permalink setting
Would anyone regex savvy be able to help me out please?
We are a podcast that talks about new games on old platforms and I am migrating the site from node.
Thank you very much in advance

mapbox-gl - how to instantiate a Map for a simple test

I'd like to start by asking Mapbox - please - to put documentation on their site that explains how to set up and start doing a simple test. There are many tests in their code on Github, but after days of reading and attempting to test I have failed to understand how they work.
I have a very simple method that:
updates some geoJson with some new coordinates and a new heading (rotation) for a marker.
uses setSource to set the changed Json to the Map
I would like to run my little method in a test and then check that the new coordinates have arrived in the Map.
Should be a piece of cake!
Now a Map needs a browser or similar. Yes, there's jsdom, which is almost certainly what is needed, but I have not discovered how you give the dom to the Map.
If I try to instantiate either window, which I found in mapbox-js utils, or Map, I get
ReferenceError: self is not defined. - 'self' appears to be the window object.
I use mocha, with babel 7, for what it's worth, but I think that all I need is to solve the mystery of setting up a Map instance so that I can then interrogate it.
Any help would be gratefully received.

Computed property doesn't update

I have the following Ember.js code (in a model):
subdata: DS.hasMany('App.Subdata'),
message_subdata: function() {
return this.get('subdata').filterBy('tag', 'message');
}.property('subdata', 'subdata.#each')
This worked just fine in RC7. In RC8+, I know they made changes to the way that observers fire, but for the life of me, I can't figure out how to get it working again. I know it says to make sure to call get before observing the property, but I'm using this property in a template, so doesn't the template have to get the property?
Right now, when the page first loads, none of the data gets shown because none of the subdata is loaded yet. That's how it's always been. But in RC7, as soon as the records were loaded, it would fire the observers and update the page. Now, for some reason, the observers aren't being update and the page won't update. The only way I can seem to force it to update is by changing the subdata property (or simulating a change with notifyPropertyChange).
How can I get my properties to work as they did in RC7?
EDIT: I thought I would give a quick update on how I did sorting AND filtering. It's probably not the best way, but I fiddled for a while to land on this solution.
subdata: DS.hasMany('App.Subdata'),
message_subdata_filtered: Ember.computed.filterBy('subdata', 'tag', 'message'),
message_subdata: Ember.computed.sort('message_subdata_filtered', function(a,b) {
return a.get('timestamp') - b.get('timestamp');
});
There might be a way to do it in one line, but this works for me.
I guess the new way of doing computed arrays is by using something like this:
subdata: DS.hasMany('App.Subdata'),
message_subdata: Ember.computed.filterBy('subdata', 'tag', 'message')

Real example of Ember.js

Please give me real example of emberjs. This example will help me understand how to write in emberjs.
Description of example:
Please open this link first:
http://jsfiddle.net/kwladyka/KhQvu/2/
(this is prototype to better understand what i am talking about)
And then read:
Emberjs download Groups.owner by JSON from json.php?name=groups-owner&user_id=58 and Groups.member from json.php?name=groups-member&user_id=58. Both in Groups.all.
In object Groups i have all values of arrays what i read from JSON. I want example read something like that: owner[2][name].
Then from CreateGroupsSelect i want read Groups.all and create ListBox with values group_id and names name. And when i change select i want change <p>You select {{name}} with id {{id}}</p> and refresh data in other View emberjs objects.
I will be really gratefull for help. I am trying learn emberjs but i totally block with this example.
Ok, so i have many questions :)
1)
How to bind value form input select to attribute in controller
var val = $('select option:selected').val();
Where can i find list of possible ussage like a "select option:selected". Any documentatin for that? Where?
2)
"didInsertElement"
How can i know i should use this? How should i looking in documentation to know that? Why not Ember.Select.Change for that?
3)
Why author use "View", i thought for select i should use class "select"?
4)
Seriously this is my first language when i fill all is so random and i dont have any idea how to know what i can write and where. I fill really stupid with that. Any hint how to understand that?
5)
Ok so step by step...
First of all i want read JSON and prepare data to use.
Organizer.Groups = Ember.Object.extend({
owner: [],
member: [],
all: function(){
var owner = this.get('owner');
var member = this.get('member');
return owner.concat(member);
}.property('owner', 'member'),
});
a) "Object" is good choice for that?
b) I want fill "owner" by array from "json.php?name=groups-owner&user_id=58". How to do that? Did i define "owner" corretly or i should write "ArrayController" or something else for that? Mayby just "Array" or "ArrayProxy"? I am filling so confuse now.
c) How should i initiate load data from JSON? I want do this only one time on the beginning.
PS Sorry if you fill my questions are so stupid but i really dont know answers and i dont hide this :)
Here is an example of how to work with select menu in Ember js
select dropdown with ember
Here is an example of working with routes and outlet helper
Right way to do navigation with Ember
If you use routing make sure you have ember latest, routing is still not released.
Router / StateManager - can't make it work
When using latest emberjs refer to documentation in source code, the documentation in ember site will be for present stable release.
https://github.com/emberjs/ember.js
The links to routing is provided from your fidle title "Router with dynamic routes"
It will be hard to solve your complete problem, give it a try starting with the routing example from above, when you are stuck ask more specific questions, we'll be happy to help.
EDIT : Some of the links are already outdated.

Facebook Group invite via Graph API

I about to built a little online game in Action Script 3. At the moment everything is working pretty fine and there is just one thing left to do that makes me going crazy. After every Level of the Game the user should notified about his success and in case that the success was good enough, the user should be invited to a facebook group. At the Moment i have got an Facebook App, Authentification and Authorisation are working and what still is to manage is the invitation itself.
Does anybody know if there is a way to make this happen, and if so, how could it be done? Thanks a lot for a reply!
greetings!
So, after having a nice day of »facebook api investigation« i would sum up the things i found out:
I'm quite sure that there is no way to make an group invitation via the graph api. The best result i could reach was an Error that told me: »requires the manage_groups permission«.
Consequently I added this permission to the login method and »tada«: the app didn't work anymore, just told me that there is an error with the app and I should try later again.
The code for getting this great message looked like this:
FB.api( "//members","POST", { name : "user name" }, function( response ){
//the great error appears here in the response
} );
I also was looking for something in the facebook.connect api but could not find something related to the problem i tried to solve.
If there is anybody who knows something better to try, i would very interested.
Greeting Philipp
Looks like "manage_groups" is not available to the public, (yet?). I'm following this and this discussion about it, as "manage_groups" seems to be required to invite a user to a group, but is not listed in the Facebook reference of extended permissions.