Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Issue 2528013002: Initialize the message center as part of the testing browser process (Closed)

Created:
4 years ago by Miguel Garcia
Modified:
4 years ago
Reviewers:
Peter Beverloo, sky
CC:
chromium-reviews, asanka, creis+watch_chromium.org, cbentzel+watch_chromium.org, sadrul, awdf+watch_chromium.org, Peter Beverloo, mlamouri+watch-notifications_chromium.org, Avi (use Gerrit), oshima+watch_chromium.org, ajwong+watch_chromium.org, kalyank, stevenjb+watch_chromium.org, davemoore+watch_chromium.org, jochen (gone - plz use gerrit)
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Initialize the message center as part of the testing browser process This allows us to remove a bunch of unnecessary initialize calls More importantly it allows us to remove test specific logic (see platform_notification_service_impl.cc) that is currently preventing us from testing those methods. This involves several other changes some (but not all) ash tests depend on message center but not on the testing browser process, the messsage center is initialized in the test suite for those tests. The browser process test uses both the testing and the real process.. A few tests were failing now that the message center lingers for longer They were fixed by re-ordering the tear down sequence. BUG=

Patch Set 1 #

Patch Set 2 : fix android tests #

Patch Set 3 : re-uploding due to time outs #

Unified diffs Side-by-side diffs Delta from patch set Stats (+60 lines, -66 lines) Patch
M ash/test/BUILD.gn View 1 chunk +1 line, -0 lines 0 comments Download
M ash/test/ash_interactive_ui_test_base.cc View 2 chunks +3 lines, -1 line 0 comments Download
M ash/test/ash_test_helper.cc View 3 chunks +0 lines, -8 lines 0 comments Download
M ash/test/test_suite.cc View 3 chunks +3 lines, -0 lines 0 comments Download
M chrome/browser/background/background_contents_service_unittest.cc View 2 chunks +0 lines, -8 lines 0 comments Download
M chrome/browser/background/background_mode_manager_unittest.cc View 2 chunks +0 lines, -7 lines 0 comments Download
M chrome/browser/browser_process_impl.h View 2 chunks +9 lines, -0 lines 0 comments Download
M chrome/browser/browser_process_impl.cc View 4 chunks +15 lines, -4 lines 0 comments Download
M chrome/browser/browser_process_impl_unittest.cc View 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/chromeos/net/network_portal_notification_controller_unittest.cc View 1 chunk +0 lines, -2 lines 0 comments Download
M chrome/browser/chromeos/net/network_state_notifier_unittest.cc View 2 chunks +0 lines, -2 lines 0 comments Download
M chrome/browser/chromeos/status/data_promo_notification_unittest.cc View 2 chunks +0 lines, -2 lines 0 comments Download
M chrome/browser/chromeos/ui/low_disk_notification_unittest.cc View 2 chunks +0 lines, -2 lines 0 comments Download
chrome/browser/download/notification/download_item_notification_unittest.cc View 2 chunks +0 lines, -2 lines 0 comments Download
M chrome/browser/notifications/message_center_notifications_unittest.cc View 2 chunks +0 lines, -12 lines 0 comments Download
M chrome/browser/notifications/notification_display_service_factory.cc View 2 chunks +8 lines, -0 lines 0 comments Download
M chrome/browser/notifications/notification_ui_manager_desktop.cc View 1 chunk +2 lines, -0 lines 0 comments Download
M chrome/browser/notifications/platform_notification_service_impl.cc View 1 chunk +10 lines, -2 lines 0 comments Download
M chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download
chrome/browser/ui/tab_contents/tab_contents_iterator_unittest.cc View 2 chunks +0 lines, -2 lines 0 comments Download
M chrome/browser/usb/web_usb_detector_unittest.cc View 2 chunks +3 lines, -3 lines 0 comments Download
M chrome/test/base/testing_browser_process.cc View 2 chunks +2 lines, -0 lines 0 comments Download
M chrome/test/base/view_event_test_platform_part_chromeos.cc View 3 chunks +1 line, -7 lines 0 comments Download

Messages

Total messages: 17 (5 generated)
Miguel Garcia
sky: You happen to be a main owner and also an ash/ owner so I ...
4 years ago (2016-11-24 16:37:30 UTC) #4
Miguel Garcia
On 2016/11/24 16:37:30, Miguel Garcia wrote: > sky: You happen to be a main owner ...
4 years ago (2016-11-24 16:38:29 UTC) #5
sky
It doesn't look like the upload succeeded (some files show missing patch). Please upload again.
4 years ago (2016-11-26 17:10:53 UTC) #8
Miguel Garcia
On 2016/11/26 17:10:53, sky wrote: > It doesn't look like the upload succeeded (some files ...
4 years ago (2016-11-28 10:47:23 UTC) #9
Miguel Garcia
On 2016/11/28 10:47:23, Miguel Garcia wrote: > On 2016/11/26 17:10:53, sky wrote: > > It ...
4 years ago (2016-11-28 10:59:49 UTC) #10
sky
I have a preference for keeping what is run by all tests to a minimum. ...
4 years ago (2016-11-28 16:17:43 UTC) #11
Miguel Garcia
On 2016/11/28 16:17:43, sky wrote: > I have a preference for keeping what is run ...
4 years ago (2016-11-28 16:33:52 UTC) #12
sky
Just because an object is a global object doesn't mean we have to initialize it ...
4 years ago (2016-11-28 17:36:25 UTC) #13
Miguel Garcia
That's how I started but I found out so many places that assume the message ...
4 years ago (2016-11-29 13:14:10 UTC) #14
sky
Thank you! On Tue, Nov 29, 2016 at 5:14 AM, <miguelg@chromium.org> wrote: > That's how ...
4 years ago (2016-11-29 18:12:46 UTC) #15
Miguel Garcia
One final thought that I forgot, right now g_browser_process->message_center() DCHECKs if the message center has ...
4 years ago (2016-11-30 13:32:14 UTC) #16
sky
4 years ago (2016-11-30 16:28:33 UTC) #17
Message was sent while issue was closed.
It's BrowserProcessImpl's a straight call through:

message_center::MessageCenter* BrowserProcessImpl::message_center() {
  DCHECK(CalledOnValidThread());
  return message_center::MessageCenter::Get();
}

Maybe you're saying you want MessageCenter::Get() to now have a
DCHECK? I'm not familiar enough with the message center code to know
the ramifications of that.

  -Scott

On Wed, Nov 30, 2016 at 5:32 AM,  <miguelg@chromium.org> wrote:
> One final thought that I forgot, right now
> g_browser_process->message_center()
> DCHECKs if the message center has not been initialized. Would it be ok to
> add a
> IsInitialized() method to message_center to overcome this problem?
>
>
> On 2016/11/29 18:12:46, sky wrote:
>> Thank you!
>>
>> On Tue, Nov 29, 2016 at 5:14 AM, <mailto:miguelg@chromium.org> wrote:
>> > That's how I started but I found out so many places that assume the
>> > message
>> > center exists (because they read it from
>> > g_browser_process->message_center()
>> > which is in fact always available in production code) that I thought it
>> > was
>> > assumed it should be.
>> >
>> > I will try a more local change to get rid of this specific problem if
>> > this
>> > is
>> > not acceptable.
>> >
>> >
>> >
>> > On 2016/11/28 17:36:25, sky wrote:
>> >> Just because an object is a global object doesn't mean we have to
>> >> initialize it for tests too. It just means code needs to be written to
>> >> deal with the possibility of the object being null. What is unique
>> >> about message center that means code can't check if it's null?
>> >>
>> >> I do agree the profile check is awful. Should the code not assume
>> >> GetNotificationDisplayService() returns a non-null?
>> >>
>> >> -Scott
>> >>
>> >> On Mon, Nov 28, 2016 at 8:33 AM, <mailto:miguelg@chromium.org> wrote:
>> >> > On 2016/11/28 16:17:43, sky wrote:
>> >> >> I have a preference for keeping what is run by all tests to a
>> >> >> minimum.
>> >> >> In
>> >> > other
>> >> >> words, tests that need message center can initialize it. Is there a
>> >> >> reason
>> >> > that
>> >> >> doesn't work well?
>> >> >
>> >> > So in general I agree with you but for better or worse the message
>> >> > center is
>> >> > a
>> >> > global object so it's accessed from random places all over the code
>> >> > base, so
>> >> > sometimes you are adding a completely unrelated change and suddenly
>> >> > test
>> >> > starts
>> >> > failing because it's missing, or double initialized.
>> >> >
>> >> > A concrete example I hit:
>> >> >
>> >> > I would like to avoid checks like
>> >> >
>> >>
>> >
>>
>
https://cs.chromium.org/chromium/src/chrome/browser/notifications/platform_no...
>> >> > where in the middle of our production code we check if the profile is
>> >> > a
>> >> > testing
>> >> > profile.
>> >> >
>> >> > This is needed today because if we actually execute the method all
>> >> > the
>> >> > tests
>> >> > that don't have a message center fail.
>> >> >
>> >> > I am changing the logic of that method (in
>> >> > https://codereview.chromium.org/2534443002/patch/40001/50003) and as
>> >> > such
>> >> > would
>> >> > like to add a unit test there but in the unit test the profile will
>> >> > be a
>> >> > testing
>> >> > profile so I would have to work around the work around. I just
>> >> > thought
>> >> > it
>> >> > would
>> >> > be better to provide the message center the same life cycle
>> >> > expectations
>> >> > in
>> >> > the
>> >> > testing browser process than in the real browser process.
>> >> >
>> >> > https://codereview.chromium.org/2528013002/
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Chromium-reviews" group.
>> >> To unsubscribe from this group and stop receiving emails from it, send
>> >> an
>> > email
>> >> to mailto:chromium-reviews+unsubscribe@chromium.org.
>> >>
>> >
>> >
>> >
>> > https://codereview.chromium.org/2528013002/
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Chromium-reviews" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
> email
>> to mailto:chromium-reviews+unsubscribe@chromium.org.
>>
>
>
>
> https://codereview.chromium.org/2528013002/

-- 
You received this message because you are subscribed to the Google Groups
"Chromium-reviews" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to chromium-reviews+unsubscribe@chromium.org.

Powered by Google App Engine
This is Rietveld 408576698