square / assertj-android

A set of AssertJ helpers geared toward testing Android.
https://square.github.io/assertj-android/
Apache License 2.0
1.58k stars 156 forks source link

Fix hasFlags method in IntentAssert #133

Closed roman-mazur closed 9 years ago

roman-mazur commented 9 years ago

Android has same values for flags FLAG_ACTIVITY_MULTIPLE_TASK and FLAG_RECEIVER_NO_ABORT. Hence, any invocation of hasFlags resulted in IllegalStateException being thrown.

Try, for example:

  @Test
  public void test() {
    assertThat(new Intent().addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT))
        .hasFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
  }

I believe we also need a project with integration tests. Where this test could be written. I personally created one to test your code from master branch. But I do not submit it here: it uses robolectric. Should I submit it? I really do not know whether this change will break something in other place. The project definitely lacks tests IMHO...

roman-mazur commented 9 years ago

Has anybody ever tried this method before?

JakeWharton commented 9 years ago

Feel free. Write them as standard android tests though, not Robolectric.

roman-mazur commented 9 years ago

I have a strange feeling that such tests should be generated... On Sep 25, 2014 6:58 PM, "Jake Wharton" notifications@github.com wrote:

Merged #133 https://github.com/square/assertj-android/pull/133.

— Reply to this email directly or view it on GitHub https://github.com/square/assertj-android/pull/133#event-170248188.

roman-mazur commented 9 years ago

Will you publish a snapshot? On Sep 25, 2014 8:40 PM, mazur.roman@gmail.com wrote:

I have a strange feeling that such tests should be generated... On Sep 25, 2014 6:58 PM, "Jake Wharton" notifications@github.com wrote:

Merged #133 https://github.com/square/assertj-android/pull/133.

— Reply to this email directly or view it on GitHub https://github.com/square/assertj-android/pull/133#event-170248188.

JakeWharton commented 9 years ago

The whole library should be generated but then you have a natural language problem and there's all kinds of special case snowflake APIs which behave differently.

And yes, I'll publish a SNAPSHOT.

roman-mazur commented 9 years ago

I'll be grateful, if you let me know when snapshot is available.

JakeWharton commented 9 years ago

Did it yesterday On Sep 26, 2014 12:37 AM, "Roman Mazur" notifications@github.com wrote:

I'll be grateful, if you let me know when snapshot is available.

— Reply to this email directly or view it on GitHub https://github.com/square/assertj-android/pull/133#issuecomment-56929071 .

roman-mazur commented 9 years ago

And where did you published it? Sonatype does not seem to host it: https://oss.sonatype.org/content/repositories/snapshots/com/squareup/assertj/

JakeWharton commented 9 years ago

It's there now.

On Fri, Sep 26, 2014 at 7:51 AM, Roman Mazur notifications@github.com wrote:

And where did you published it? Sonatype does not seem to host it: https://oss.sonatype.org/content/repositories/snapshots/com/squareup/assertj/

— Reply to this email directly or view it on GitHub https://github.com/square/assertj-android/pull/133#issuecomment-56971913 .