Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Robolectric updated to Jelly Bean (API 16)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Michael Portuesi  
View profile  
 More options Sep 17 2012, 3:23 pm
From: Michael Portuesi <mportues...@gmail.com>
Date: Mon, 17 Sep 2012 12:23:09 -0700 (PDT)
Local: Mon, Sep 17 2012 3:23 pm
Subject: Robolectric updated to Jelly Bean (API 16)

Hi there,

A week or so ago, the Maven public repos put up an android.jar file built
against the Jelly Bean (API 16) sources.  So I have updated Robolectric to
build against the API 16 version of android.jar and I've pushed those
changes to the pivotal master repo.

It appears that Google may have eliminated, not just deprecated, a few
entry points from the WebSettings class in API 16.  So if you have tests
that use WebSettings you may possibly run into issues. If so, please post
to this group and I'll try to help sort things out.

Regards,
Michael Portuesi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sd2011  
View profile  
 More options Oct 23 2012, 5:43 pm
From: sd2011 <ericsd2...@gmail.com>
Date: Tue, 23 Oct 2012 14:43:40 -0700 (PDT)
Local: Tues, Oct 23 2012 5:43 pm
Subject: Re: Robolectric updated to Jelly Bean (API 16)

Hi Michael,
i think my issue might be related...is there a way you can take a look and
provide guidance?
I just posted my question before finding your post on the same forum.

https://groups.google.com/forum/#!topic/robolectric/ritLOTW0JAU


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Portuesi  
View profile  
 More options Oct 23 2012, 6:38 pm
From: Michael Portuesi <mportues...@gmail.com>
Date: Tue, 23 Oct 2012 15:38:20 -0700
Local: Tues, Oct 23 2012 6:38 pm
Subject: Re: [robolectric] Re: Robolectric updated to Jelly Bean (API 16)

Hi there sd2011,

You are correct that WebSettings became an abstract class in API 16.

At API 16, Robolectric could no longer create an instance of WebSettings
via:

private WebSettings webSettings =
Robolectric.newInstanceOf(WebSettings.class);

because WebSettings is abstract and cannot be instantiated even by
reflection.

Because WebSettings became abstract, Robolectric has to somehow offer a
concrete instantiation of WebSettings.  So I created the
android.webkit.TestWebSettings class, and made Robolectric return an
instance of that in ShadowWebView#getSettings.

There's some things I don't like about this approach:

1) TestWebSettings resides in the android.webkit package, and not in any
Robolectric package.  That's because Google, in their infinite wisdom, made
the constructors for WebSettings package-protected, and so any subclass
must reside in the same package as WebSettings.

2) The ShadowWebSettings class went away entirely, with all of its code
moving into TestWebSettings.  I got rid of ShadowWebSettings mainly because
I didn't want two copy/paste implementations of the same code lying around
in Robolectric - it would have been a maintenance nightmare waiting to
happen.  (There may also have been either a compile-time or runtime problem
with keeping a shadow for an abstract class, but my memory is hazy).

As to the problem you reported in your StackOverflow post -  that you
switched to API 12 but still cannot instantiate WebSettings.  This is
likely to be the case even if you change your project to a lower API level,
because Robolectric itself is still built against the android-16.jar.  If
you change Robolectric itself to build against android-12.jar, you will get
an instance of WebSettings - but without a shadow implementation
because ShadowWebSettings has been removed from the current version of
Robolectric.

The easiest workaround for your problem would probably be to update your
project to API 16, and then instantiate a TestWebSettings object directly
in your test case.  So instead of:

private WebSettings webSettings =
Robolectric.newInstanceOf(WebSettings.class);

you would write:

    private WebSettings webSettings = new TestWebSettings();

Robolectric ideally should have some type of mechanism that allows it to
serve up one of several alternate implementations of WebSettings based upon
Android API level.  What I'm not yet convinced of is whether the resulting
source code can build against any Android API jar without modification, or
whether we would need to build several jar files for Robolectric, one
targeting each version of the API.

Best regards,
Michael Portuesi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sd2011  
View profile  
 More options Oct 23 2012, 7:00 pm
From: sd2011 <ericsd2...@gmail.com>
Date: Tue, 23 Oct 2012 16:00:44 -0700 (PDT)
Local: Tues, Oct 23 2012 7:00 pm
Subject: Re: Robolectric updated to Jelly Bean (API 16)

Hi Michael
Thank you for your reply, and all the details you provided.  I almost cried
when I saw your reply, as I have been stuck by this for a while now.
What you said totally makes sense, I also tried  to create my own concrete
class of WebSettings, but like you said, it is package protected, so my
approach failed.

I was wondering where I can find your TestWebSettings class?
I assume I don't have it and i need to get it somewhere, I was browsing
manually https://github.com/pivotal/robolectric
but I could not find it...(is there a search button)?

Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sd2011  
View profile  
 More options Oct 23 2012, 7:03 pm
From: sd2011 <ericsd2...@gmail.com>
Date: Tue, 23 Oct 2012 16:03:29 -0700 (PDT)
Local: Tues, Oct 23 2012 7:03 pm
Subject: Re: Robolectric updated to Jelly Bean (API 16)

OH never mind
found it

https://github.com/pivotal/robolectric/tree/master/src/main/java/andr...
Thanks Michael!!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Portuesi  
View profile  
 More options Oct 23 2012, 7:15 pm
From: Michael Portuesi <mportues...@gmail.com>
Date: Tue, 23 Oct 2012 16:15:25 -0700
Local: Tues, Oct 23 2012 7:15 pm
Subject: Re: [robolectric] Re: Robolectric updated to Jelly Bean (API 16)

Eric,

Please accept my apology for causing you an inconvenience, and I'm glad I
could be helpful.

In the short term, I will see if there's a simple way the ShadowWebSettings
class can be re-introduced so that Robolectric can serve lower API levels.
 I think the immediate reason why I took it out (other than code
duplication) is that since ShadowWebSettings was shadowing an abstract
class, that it was failing the Robolectric wiring tests.  I'll have to
repeat that experiment to see what can be done.

Regards,
Michael Portuesi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sd2011  
View profile  
 More options Oct 23 2012, 8:19 pm
From: sd2011 <ericsd2...@gmail.com>
Date: Tue, 23 Oct 2012 17:19:09 -0700 (PDT)
Local: Tues, Oct 23 2012 8:19 pm
Subject: Re: [robolectric] Re: Robolectric updated to Jelly Bean (API 16)

No apologies needed Michael!  What you did and said made sense.  It's just
that i become panicky when i could not find any solution to this initially,
i am glad i asked it here and not just stack overflow.  Nonetheless, thank
you for your speedy replies and thoughts on this issue...i looked for a
solution and i got it...all good now

thanks again Michael


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »