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

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_image_model_browsertest.cc

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/ui/content_settings/content_setting_image_model.h"
6
7 #include "base/memory/ptr_util.h"
5 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
6 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
7 #include "chrome/browser/ui/content_settings/content_setting_image_model.h"
8 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
9 #include "chrome/test/base/in_process_browser_test.h" 11 #include "chrome/test/base/in_process_browser_test.h"
10 12
11 using content::WebContents; 13 using content::WebContents;
12 14
13 typedef InProcessBrowserTest ContentSettingImageModelBrowserTest; 15 typedef InProcessBrowserTest ContentSettingImageModelBrowserTest;
14 16
15 // Tests that every model creates a valid bubble. 17 // Tests that every model creates a valid bubble.
16 IN_PROC_BROWSER_TEST_F(ContentSettingImageModelBrowserTest, CreateBubbleModel) { 18 IN_PROC_BROWSER_TEST_F(ContentSettingImageModelBrowserTest, CreateBubbleModel) {
17 WebContents* web_contents = 19 WebContents* web_contents =
(...skipping 13 matching lines...) Expand all
31 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, 33 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT,
32 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, 34 CONTENT_SETTINGS_TYPE_PPAPI_BROKER,
33 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, 35 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
34 CONTENT_SETTINGS_TYPE_GEOLOCATION, 36 CONTENT_SETTINGS_TYPE_GEOLOCATION,
35 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, 37 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS,
36 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, 38 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
37 }; 39 };
38 40
39 Profile* profile = browser()->profile(); 41 Profile* profile = browser()->profile();
40 for (ContentSettingsType type : content_settings_to_test) { 42 for (ContentSettingsType type : content_settings_to_test) {
41 scoped_ptr<ContentSettingBubbleModel> bubble( 43 std::unique_ptr<ContentSettingBubbleModel> bubble(
42 ContentSettingSimpleImageModel::CreateForContentTypeForTesting(type) 44 ContentSettingSimpleImageModel::CreateForContentTypeForTesting(type)
43 ->CreateBubbleModel(nullptr, web_contents, profile)); 45 ->CreateBubbleModel(nullptr, web_contents, profile));
44 46
45 // All of the above content settings should create a 47 // All of the above content settings should create a
46 // ContentSettingSimpleBubbleModel that is tied to a particular setting, 48 // ContentSettingSimpleBubbleModel that is tied to a particular setting,
47 // and thus it should be an instance of ContentSettingSimpleBubbleModel. 49 // and thus it should be an instance of ContentSettingSimpleBubbleModel.
48 ContentSettingSimpleBubbleModel* simple_bubble = 50 ContentSettingSimpleBubbleModel* simple_bubble =
49 bubble->AsSimpleBubbleModel(); 51 bubble->AsSimpleBubbleModel();
50 ASSERT_TRUE(simple_bubble); 52 ASSERT_TRUE(simple_bubble);
51 EXPECT_EQ(type, simple_bubble->content_type()); 53 EXPECT_EQ(type, simple_bubble->content_type());
52 } 54 }
53 55
54 // For other models, we can only test that they create a valid bubble. 56 // For other models, we can only test that they create a valid bubble.
55 ScopedVector<ContentSettingImageModel> models = 57 ScopedVector<ContentSettingImageModel> models =
56 ContentSettingImageModel::GenerateContentSettingImageModels(); 58 ContentSettingImageModel::GenerateContentSettingImageModels();
57 for (ContentSettingImageModel* model : models) { 59 for (ContentSettingImageModel* model : models) {
58 EXPECT_TRUE(make_scoped_ptr( 60 EXPECT_TRUE(base::WrapUnique(
59 model->CreateBubbleModel(nullptr, web_contents, profile)) 61 model->CreateBubbleModel(nullptr, web_contents, profile))
60 .get()); 62 .get());
61 } 63 }
62 } 64 }
63 65
64 // Tests that we correctly remember for which WebContents the animation has run, 66 // Tests that we correctly remember for which WebContents the animation has run,
65 // and thus we should not run it again. 67 // and thus we should not run it again.
66 IN_PROC_BROWSER_TEST_F(ContentSettingImageModelBrowserTest, 68 IN_PROC_BROWSER_TEST_F(ContentSettingImageModelBrowserTest,
67 ShouldRunAnimation) { 69 ShouldRunAnimation) {
68 WebContents* web_contents = 70 WebContents* web_contents =
69 browser()->tab_strip_model()->GetActiveWebContents(); 71 browser()->tab_strip_model()->GetActiveWebContents();
70 72
71 scoped_ptr<ContentSettingImageModel> model = 73 std::unique_ptr<ContentSettingImageModel> model =
72 ContentSettingSimpleImageModel::CreateForContentTypeForTesting( 74 ContentSettingSimpleImageModel::CreateForContentTypeForTesting(
73 CONTENT_SETTINGS_TYPE_IMAGES); 75 CONTENT_SETTINGS_TYPE_IMAGES);
74 76
75 EXPECT_TRUE(model->ShouldRunAnimation(web_contents)); 77 EXPECT_TRUE(model->ShouldRunAnimation(web_contents));
76 model->SetAnimationHasRun(web_contents); 78 model->SetAnimationHasRun(web_contents);
77 EXPECT_FALSE(model->ShouldRunAnimation(web_contents)); 79 EXPECT_FALSE(model->ShouldRunAnimation(web_contents));
78 80
79 // The animation has run for the current WebContents, but not for any other. 81 // The animation has run for the current WebContents, but not for any other.
80 Profile* profile = browser()->profile(); 82 Profile* profile = browser()->profile();
81 WebContents::CreateParams create_params(profile); 83 WebContents::CreateParams create_params(profile);
82 WebContents* other_web_contents = WebContents::Create(create_params); 84 WebContents* other_web_contents = WebContents::Create(create_params);
83 browser()->tab_strip_model()->TabStripModel::AppendWebContents( 85 browser()->tab_strip_model()->TabStripModel::AppendWebContents(
84 other_web_contents, true); 86 other_web_contents, true);
85 EXPECT_TRUE(model->ShouldRunAnimation(other_web_contents)); 87 EXPECT_TRUE(model->ShouldRunAnimation(other_web_contents));
86 } 88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698