OLD | NEW |
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/common/shelf/shelf_model.h" | 5 #include "ash/common/shelf/shelf_model.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ash/common/shelf/shelf_model_observer.h" | 10 #include "ash/common/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 // ShelfModelObserver implementation that tracks what message are invoked. | 18 // ShelfModelObserver implementation that tracks what message are invoked. |
19 class TestShelfModelObserver : public ShelfModelObserver { | 19 class TestShelfModelObserver : public ShelfModelObserver { |
20 public: | 20 public: |
21 TestShelfModelObserver() | 21 TestShelfModelObserver() |
22 : added_count_(0), | 22 : added_count_(0), |
23 removed_count_(0), | 23 removed_count_(0), |
24 changed_count_(0), | 24 changed_count_(0), |
25 moved_count_(0) { | 25 moved_count_(0) {} |
26 } | |
27 | 26 |
28 // Returns a string description of the changes that have occurred since this | 27 // Returns a string description of the changes that have occurred since this |
29 // was last invoked. Resets state to initial state. | 28 // was last invoked. Resets state to initial state. |
30 std::string StateStringAndClear() { | 29 std::string StateStringAndClear() { |
31 std::string result; | 30 std::string result; |
32 AddToResult("added=%d", added_count_, &result); | 31 AddToResult("added=%d", added_count_, &result); |
33 AddToResult("removed=%d", removed_count_, &result); | 32 AddToResult("removed=%d", removed_count_, &result); |
34 AddToResult("changed=%d", changed_count_, &result); | 33 AddToResult("changed=%d", changed_count_, &result); |
35 AddToResult("moved=%d", moved_count_, &result); | 34 AddToResult("moved=%d", moved_count_, &result); |
36 added_count_ = removed_count_ = changed_count_ = moved_count_ = 0; | 35 added_count_ = removed_count_ = changed_count_ = moved_count_ = 0; |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 // Now change the type of the second item and make sure that it is moving | 339 // Now change the type of the second item and make sure that it is moving |
341 // behind the shortcuts. | 340 // behind the shortcuts. |
342 item.type = TYPE_PLATFORM_APP; | 341 item.type = TYPE_PLATFORM_APP; |
343 model_->Set(app2_index, item); | 342 model_->Set(app2_index, item); |
344 | 343 |
345 // The item should have moved in front of the app launcher. | 344 // The item should have moved in front of the app launcher. |
346 EXPECT_EQ(TYPE_PLATFORM_APP, model_->items()[4].type); | 345 EXPECT_EQ(TYPE_PLATFORM_APP, model_->items()[4].type); |
347 } | 346 } |
348 | 347 |
349 } // namespace ash | 348 } // namespace ash |
OLD | NEW |