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

Side by Side Diff: content/browser/web_contents/web_contents_user_data_unittest.cc

Issue 1874893002: Convert //content/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/public/browser/web_contents_user_data.h" 5 #include "content/public/browser/web_contents_user_data.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include <memory>
8
8 #include "content/public/browser/web_contents.h" 9 #include "content/public/browser/web_contents.h"
9 #include "content/public/test/test_renderer_host.h" 10 #include "content/public/test/test_renderer_host.h"
10 #include "content/public/test/web_contents_tester.h" 11 #include "content/public/test/web_contents_tester.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace content { 14 namespace content {
14 15
15 class WebContentsAttachedClass1 16 class WebContentsAttachedClass1
16 : public WebContentsUserData<WebContentsAttachedClass1> { 17 : public WebContentsUserData<WebContentsAttachedClass1> {
17 public: 18 public:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 WebContentsAttachedClass1::FromWebContents(contents); 58 WebContentsAttachedClass1::FromWebContents(contents);
58 ASSERT_TRUE(class1again != NULL); 59 ASSERT_TRUE(class1again != NULL);
59 class2 = WebContentsAttachedClass2::FromWebContents(contents); 60 class2 = WebContentsAttachedClass2::FromWebContents(contents);
60 ASSERT_TRUE(class2 != NULL); 61 ASSERT_TRUE(class2 != NULL);
61 ASSERT_EQ(class1, class1again); 62 ASSERT_EQ(class1, class1again);
62 ASSERT_NE(static_cast<void*>(class1), static_cast<void*>(class2)); 63 ASSERT_NE(static_cast<void*>(class1), static_cast<void*>(class2));
63 } 64 }
64 65
65 TEST_F(WebContentsUserDataTest, TwoInstancesOneAttachment) { 66 TEST_F(WebContentsUserDataTest, TwoInstancesOneAttachment) {
66 WebContents* contents1 = web_contents(); 67 WebContents* contents1 = web_contents();
67 scoped_ptr<WebContents> contents2( 68 std::unique_ptr<WebContents> contents2(
68 WebContentsTester::CreateTestWebContents(browser_context(), NULL)); 69 WebContentsTester::CreateTestWebContents(browser_context(), NULL));
69 70
70 WebContentsAttachedClass1* one_class = 71 WebContentsAttachedClass1* one_class =
71 WebContentsAttachedClass1::FromWebContents(contents1); 72 WebContentsAttachedClass1::FromWebContents(contents1);
72 ASSERT_EQ(NULL, one_class); 73 ASSERT_EQ(NULL, one_class);
73 WebContentsAttachedClass1* two_class = 74 WebContentsAttachedClass1* two_class =
74 WebContentsAttachedClass1::FromWebContents(contents2.get()); 75 WebContentsAttachedClass1::FromWebContents(contents2.get());
75 ASSERT_EQ(NULL, two_class); 76 ASSERT_EQ(NULL, two_class);
76 77
77 WebContentsAttachedClass1::CreateForWebContents(contents1); 78 WebContentsAttachedClass1::CreateForWebContents(contents1);
(...skipping 23 matching lines...) Expand all
101 ASSERT_TRUE(clazz != NULL); 102 ASSERT_TRUE(clazz != NULL);
102 103
103 WebContentsAttachedClass1::CreateForWebContents(contents); 104 WebContentsAttachedClass1::CreateForWebContents(contents);
104 WebContentsAttachedClass1* class_again = 105 WebContentsAttachedClass1* class_again =
105 WebContentsAttachedClass1::FromWebContents(contents); 106 WebContentsAttachedClass1::FromWebContents(contents);
106 ASSERT_TRUE(class_again != NULL); 107 ASSERT_TRUE(class_again != NULL);
107 ASSERT_EQ(clazz, class_again); 108 ASSERT_EQ(clazz, class_again);
108 } 109 }
109 110
110 } // namespace content 111 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl_unittest.cc ('k') | content/browser/web_contents/web_contents_view_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698