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

Side by Side Diff: ash/shelf/shelf_model_unittest.cc

Issue 2869473002: Fix crash on openning settings when DCHECK is on. (Closed)
Patch Set: use new id for app list Created 3 years, 7 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 "ash/shelf/shelf_model.h" 5 #include "ash/shelf/shelf_model.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "ash/shelf/shelf_model_observer.h" 10 #include "ash/shelf/shelf_model_observer.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace ash { 14 namespace ash {
15 15
16 namespace { 16 namespace {
17 17
18 constexpr char kAppListId[] = "jlfapfmkapbjlfbpjedlinehodkccjee";
19
18 // ShelfModelObserver implementation that tracks what message are invoked. 20 // ShelfModelObserver implementation that tracks what message are invoked.
19 class TestShelfModelObserver : public ShelfModelObserver { 21 class TestShelfModelObserver : public ShelfModelObserver {
20 public: 22 public:
21 TestShelfModelObserver() {} 23 TestShelfModelObserver() {}
22 24
23 // Returns a string description of the changes that have occurred since this 25 // Returns a string description of the changes that have occurred since this
24 // was last invoked. Resets state to initial state. 26 // was last invoked. Resets state to initial state.
25 std::string StateStringAndClear() { 27 std::string StateStringAndClear() {
26 std::string result; 28 std::string result;
27 AddToResult("added=%d", added_count_, &result); 29 AddToResult("added=%d", added_count_, &result);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 ShelfModelTest() {} 64 ShelfModelTest() {}
63 ~ShelfModelTest() override {} 65 ~ShelfModelTest() override {}
64 66
65 void SetUp() override { 67 void SetUp() override {
66 model_.reset(new ShelfModel); 68 model_.reset(new ShelfModel);
67 observer_.reset(new TestShelfModelObserver); 69 observer_.reset(new TestShelfModelObserver);
68 EXPECT_EQ(0, model_->item_count()); 70 EXPECT_EQ(0, model_->item_count());
69 71
70 ShelfItem item; 72 ShelfItem item;
71 item.type = TYPE_APP_LIST; 73 item.type = TYPE_APP_LIST;
72 item.id = ShelfID("AppListId"); 74 item.id = ShelfID(kAppListId);
73 model_->Add(item); 75 model_->Add(item);
74 EXPECT_EQ(1, model_->item_count()); 76 EXPECT_EQ(1, model_->item_count());
75 77
76 model_->AddObserver(observer_.get()); 78 model_->AddObserver(observer_.get());
77 } 79 }
78 80
79 void TearDown() override { 81 void TearDown() override {
80 observer_.reset(); 82 observer_.reset();
81 model_.reset(); 83 model_.reset();
82 } 84 }
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 430
429 // Unpinning the same app id again should have no change. 431 // Unpinning the same app id again should have no change.
430 model_->UnpinAppWithID(app_id); 432 model_->UnpinAppWithID(app_id);
431 EXPECT_FALSE(model_->IsAppPinned(app_id)); 433 EXPECT_FALSE(model_->IsAppPinned(app_id));
432 EXPECT_EQ(2, model_->item_count()); 434 EXPECT_EQ(2, model_->item_count());
433 EXPECT_EQ(TYPE_APP, model_->items()[index].type); 435 EXPECT_EQ(TYPE_APP, model_->items()[index].type);
434 EXPECT_EQ(item.id, model_->items()[index].id); 436 EXPECT_EQ(item.id, model_->items()[index].id);
435 } 437 }
436 438
437 } // namespace ash 439 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/app_list_shelf_item_delegate.cc ('k') | chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698