Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support appcompat-v7 #1446

Closed
erd opened this issue Dec 31, 2014 · 12 comments
Closed

Support appcompat-v7 #1446

erd opened this issue Dec 31, 2014 · 12 comments
Milestone

Comments

@erd
Copy link
Member

erd commented Dec 31, 2014

No description provided.

@simtse
Copy link

simtse commented Jan 12, 2015

Hello @erd , so I guess these fixes to the v7 ActionBarActivity will only be available in 3.0 of Robolectic and not in 2.4?

@erd
Copy link
Member Author

erd commented Jan 12, 2015

Yes, only 3.0.

@nenick
Copy link
Contributor

nenick commented Feb 24, 2015

The old depricated ActionbarDrawerToggle used android.R.attr.homeAsUpIndicator instead of R.id.home
So a workaround which works for me is to shadow this class and use the original attr value.

import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.support.v7.app.ActionBarDrawerToggle;

import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Implements;

@Implements(ActionBarDrawerToggle.class)
public class ShadowActionBarDrawerToggle {

    public Drawable getThemeUpIndicator() {
        final TypedArray a = RuntimeEnvironment.application.obtainStyledAttributes(new int[]{android.R.attr.homeAsUpIndicator});
        final Drawable result = a.getDrawable(0);
        a.recycle();
        return result;
    }
}

@LeFrenchTouch
Copy link

Thanks a ton for documenting a fix @nenick !!

@karlicoss
Copy link
Contributor

Sorry, I don't really get it guys.. Has any ActionBarActivity support been implemented and merged into 3.0-SNAPSHOT?

@nenick
Copy link
Contributor

nenick commented Mar 19, 2015

ActionBarActivity and Robolectric works together. Here is a basic example https://github.com/robolectric/robolectric-samples/tree/master/android-appcompat-v7

@erd
Copy link
Member Author

erd commented Mar 19, 2015

@karlicoss Yes, it should work. Please open issues for anything you find in appcompat that doesn't work as you'd expect.

@erd erd closed this as completed Mar 19, 2015
@karlicoss
Copy link
Contributor

Thanks for the link guys, I managed to localize the problem. I was getting weird FileNotFoundExceptiions while inflating the layout for ActionBarActivity, turns out, inflating is ok, the problem is rather in the <include layout=.../> tag. I'll open an issue or make a PR once I investigate that.

@ajhuntsman
Copy link

FYI - I filed a new issue re: ActionBarActivity with 3.0-SNAPSHOT: #1636

@yousufsyed
Copy link

It worked for me after updating the following in the build.gradle file:
dependencies {
.....
compile 'com.android.support:appcompat-v7:22.0.0'
.....
// Robolectric
testCompile 'junit:junit:4.12'
testCompile('org.robolectric:shadows-support-v4:3.0-rc2')
testCompile('org.robolectric:robolectric:3.0-rc2')

}

android {
....
buildToolsVersion '21.1.2'
.....
}

@hidroh
Copy link
Contributor

hidroh commented Apr 5, 2015

@karlicoss I'm having the same problem with FileNotFoundException when using <include layout=.../> tag as well. Did you manage to work around it?

@karlicoss
Copy link
Contributor

@hidroh not really. Didn't have much time to investigate, so I just inlined this layout. I have a separate flavor for robolectric tests in my project, so it didn't affect the production code, just some copy-pasting. It was the only test that caused crashes, so it's not that bad (at least, yet).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants