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

Side by Side Diff: chrome/browser/ui/app_list/test/fast_show_pickler_unittest.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/app_list/fast_show_pickler.h"
6
5 #include <stddef.h> 7 #include <stddef.h>
6 8
7 #include "chrome/browser/ui/app_list/fast_show_pickler.h" 9 #include "base/memory/ptr_util.h"
8 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/skia/include/core/SkBitmap.h" 11 #include "third_party/skia/include/core/SkBitmap.h"
10 #include "third_party/skia/include/core/SkColorPriv.h" 12 #include "third_party/skia/include/core/SkColorPriv.h"
11 #include "ui/app_list/app_list_item.h" 13 #include "ui/app_list/app_list_item.h"
12 #include "ui/app_list/app_list_model.h" 14 #include "ui/app_list/app_list_model.h"
13 #include "ui/app_list/test/app_list_test_model.h" 15 #include "ui/app_list/test/app_list_test_model.h"
14 #include "ui/gfx/image/image_skia.h" 16 #include "ui/gfx/image/image_skia.h"
15 #include "ui/gfx/skia_util.h" 17 #include "ui/gfx/skia_util.h"
16 18
17 using app_list::AppListItem; 19 using app_list::AppListItem;
(...skipping 21 matching lines...) Expand all
39 std::vector<gfx::ImageSkiaRep> reps1(image1.image_reps()); 41 std::vector<gfx::ImageSkiaRep> reps1(image1.image_reps());
40 std::vector<gfx::ImageSkiaRep> reps2(image2.image_reps()); 42 std::vector<gfx::ImageSkiaRep> reps2(image2.image_reps());
41 ASSERT_EQ(reps1.size(), reps2.size()); 43 ASSERT_EQ(reps1.size(), reps2.size());
42 for (size_t i = 0; i < reps1.size(); ++i) { 44 for (size_t i = 0; i < reps1.size(); ++i) {
43 ASSERT_TRUE( 45 ASSERT_TRUE(
44 gfx::BitmapsAreEqual(reps1[i].sk_bitmap(), reps2[i].sk_bitmap())); 46 gfx::BitmapsAreEqual(reps1[i].sk_bitmap(), reps2[i].sk_bitmap()));
45 ASSERT_EQ(reps1[i].scale(), reps2[i].scale()); 47 ASSERT_EQ(reps1[i].scale(), reps2[i].scale());
46 } 48 }
47 } 49 }
48 50
49 scoped_ptr<AppListModel> CopyViaPickle(AppListModel* model) { 51 std::unique_ptr<AppListModel> CopyViaPickle(AppListModel* model) {
50 scoped_ptr<base::Pickle> pickle( 52 std::unique_ptr<base::Pickle> pickle(
51 FastShowPickler::PickleAppListModelForFastShow(model)); 53 FastShowPickler::PickleAppListModelForFastShow(model));
52 return FastShowPickler::UnpickleAppListModelForFastShow(pickle.get()); 54 return FastShowPickler::UnpickleAppListModelForFastShow(pickle.get());
53 } 55 }
54 56
55 void DoConsistencyChecks(AppListModel* model) { 57 void DoConsistencyChecks(AppListModel* model) {
56 scoped_ptr<AppListModel> model2(CopyViaPickle(model)); 58 std::unique_ptr<AppListModel> model2(CopyViaPickle(model));
57 AppListModel dest_model; 59 AppListModel dest_model;
58 FastShowPickler::CopyOver(model2.get(), &dest_model); 60 FastShowPickler::CopyOver(model2.get(), &dest_model);
59 61
60 CheckIsSame(model, model2.get()); 62 CheckIsSame(model, model2.get());
61 CheckIsSame(model, &dest_model); 63 CheckIsSame(model, &dest_model);
62 CheckIsSame(model2.get(), &dest_model); 64 CheckIsSame(model2.get(), &dest_model);
63 } 65 }
64 66
65 gfx::ImageSkia MakeImage() { 67 gfx::ImageSkia MakeImage() {
66 const int kWidth = 10; 68 const int kWidth = 10;
67 const int kHeight = 10; 69 const int kHeight = 10;
68 SkBitmap bitmap; 70 SkBitmap bitmap;
69 bitmap.allocN32Pixels(kWidth, kHeight); 71 bitmap.allocN32Pixels(kWidth, kHeight);
70 bitmap.eraseARGB(255, 1, 2, 3); 72 bitmap.eraseARGB(255, 1, 2, 3);
71 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); 73 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
72 } 74 }
73 }; 75 };
74 76
75 TEST_F(AppListModelPicklerUnitTest, EmptyModel) { 77 TEST_F(AppListModelPicklerUnitTest, EmptyModel) {
76 AppListModel model; 78 AppListModel model;
77 DoConsistencyChecks(&model); 79 DoConsistencyChecks(&model);
78 } 80 }
79 81
80 TEST_F(AppListModelPicklerUnitTest, OneItem) { 82 TEST_F(AppListModelPicklerUnitTest, OneItem) {
81 AppListModel model; 83 AppListModel model;
82 model.AddItem(make_scoped_ptr(new AppListItem("abc"))); 84 model.AddItem(base::WrapUnique(new AppListItem("abc")));
83 DoConsistencyChecks(&model); 85 DoConsistencyChecks(&model);
84 } 86 }
85 87
86 TEST_F(AppListModelPicklerUnitTest, TwoItems) { 88 TEST_F(AppListModelPicklerUnitTest, TwoItems) {
87 AppListModel model; 89 AppListModel model;
88 AppListItem* app1 = model.AddItem(make_scoped_ptr(new AppListItem("abc"))); 90 AppListItem* app1 = model.AddItem(base::WrapUnique(new AppListItem("abc")));
89 model.SetItemNameAndShortName(app1, "hello, there", "ht"); 91 model.SetItemNameAndShortName(app1, "hello, there", "ht");
90 AppListItem* app2 = model.AddItem(make_scoped_ptr(new AppListItem("abc2"))); 92 AppListItem* app2 = model.AddItem(base::WrapUnique(new AppListItem("abc2")));
91 model.SetItemNameAndShortName(app2, "hello, there 2", "ht2"); 93 model.SetItemNameAndShortName(app2, "hello, there 2", "ht2");
92 94
93 DoConsistencyChecks(&model); 95 DoConsistencyChecks(&model);
94 } 96 }
95 97
96 TEST_F(AppListModelPicklerUnitTest, Images) { 98 TEST_F(AppListModelPicklerUnitTest, Images) {
97 AppListModel model; 99 AppListModel model;
98 AppListItem* app1 = model.AddItem(make_scoped_ptr(new AppListItem("abc"))); 100 AppListItem* app1 = model.AddItem(base::WrapUnique(new AppListItem("abc")));
99 model.SetItemName(app1, "hello, there"); 101 model.SetItemName(app1, "hello, there");
100 app1->SetIcon(MakeImage()); 102 app1->SetIcon(MakeImage());
101 AppListItem* app2 = model.AddItem(make_scoped_ptr(new AppListItem("abc2"))); 103 AppListItem* app2 = model.AddItem(base::WrapUnique(new AppListItem("abc2")));
102 model.SetItemName(app2, "hello, there 2"); 104 model.SetItemName(app2, "hello, there 2");
103 105
104 DoConsistencyChecks(&model); 106 DoConsistencyChecks(&model);
105 } 107 }
106 108
107 TEST_F(AppListModelPicklerUnitTest, EmptyImage) { 109 TEST_F(AppListModelPicklerUnitTest, EmptyImage) {
108 AppListModel model; 110 AppListModel model;
109 AppListItem* app1 = model.AddItem(make_scoped_ptr(new AppListItem("abc"))); 111 AppListItem* app1 = model.AddItem(base::WrapUnique(new AppListItem("abc")));
110 model.SetItemName(app1, "hello, there"); 112 model.SetItemName(app1, "hello, there");
111 app1->SetIcon(gfx::ImageSkia()); 113 app1->SetIcon(gfx::ImageSkia());
112 114
113 DoConsistencyChecks(&model); 115 DoConsistencyChecks(&model);
114 } 116 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/test/fake_profile.cc ('k') | chrome/browser/ui/apps/chrome_app_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698