Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / devtools / device / webrtc / webrtc_device_provider_browsertest.cc
blob3b461ff0b9db4707efd70f2f528451a49531eaef
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.
5 #include "base/bind.h"
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 {
19 protected:
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(
30 browser()->profile(),
31 SigninManagerFactory::GetForProfile(browser()->profile()),
32 ProfileOAuth2TokenServiceFactory::GetForProfile(browser()->profile()));
35 // static
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(
43 BrowserThread::IO,
44 FROM_HERE,
45 base::Bind(&Unreference, CreateProvider()),
46 runner->QuitClosure());
47 runner->Run();
50 IN_PROC_BROWSER_TEST_F(WebRtcDeviceProviderTest, OutliveProfile) {
51 provider_ = CreateProvider();