1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 #include "chrome/browser/devtools/device/webrtc/webrtc_device_provider.h"
7 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
8 #include "chrome/browser/signin/signin_manager_factory.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "components/signin/core/browser/signin_manager.h"
12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/test/test_utils.h"
15 using content::BrowserThread
;
16 using content::MessageLoopRunner
;
18 class WebRtcDeviceProviderTest
: public InProcessBrowserTest
{
20 scoped_refptr
<WebRTCDeviceProvider
> CreateProvider();
21 static void Unreference(
22 scoped_refptr
<WebRTCDeviceProvider
> provider
);
24 scoped_refptr
<WebRTCDeviceProvider
> provider_
;
27 scoped_refptr
<WebRTCDeviceProvider
>
28 WebRtcDeviceProviderTest::CreateProvider() {
29 return new WebRTCDeviceProvider(
31 SigninManagerFactory::GetForProfile(browser()->profile()),
32 ProfileOAuth2TokenServiceFactory::GetForProfile(browser()->profile()));
36 void WebRtcDeviceProviderTest::Unreference(
37 scoped_refptr
<WebRTCDeviceProvider
> provider
) {
40 IN_PROC_BROWSER_TEST_F(WebRtcDeviceProviderTest
, TestDeleteSelf
) {
41 scoped_refptr
<MessageLoopRunner
> runner
= new MessageLoopRunner
;
42 BrowserThread::PostTaskAndReply(
45 base::Bind(&Unreference
, CreateProvider()),
46 runner
->QuitClosure());
50 IN_PROC_BROWSER_TEST_F(WebRtcDeviceProviderTest
, OutliveProfile
) {
51 provider_
= CreateProvider();