OLD | NEW |
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 "ash/launcher/launcher_view.h" | 5 #include "ash/launcher/launcher_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/launcher/launcher.h" | 10 #include "ash/launcher/launcher.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 void RemoveByID(LauncherID id) { | 196 void RemoveByID(LauncherID id) { |
197 model_->RemoveItemAt(model_->ItemIndexByID(id)); | 197 model_->RemoveItemAt(model_->ItemIndexByID(id)); |
198 test_api_->RunMessageLoopUntilAnimationsDone(); | 198 test_api_->RunMessageLoopUntilAnimationsDone(); |
199 } | 199 } |
200 | 200 |
201 internal::LauncherButton* GetButtonByID(LauncherID id) { | 201 internal::LauncherButton* GetButtonByID(LauncherID id) { |
202 int index = model_->ItemIndexByID(id); | 202 int index = model_->ItemIndexByID(id); |
203 return test_api_->GetButton(index); | 203 return test_api_->GetButton(index); |
204 } | 204 } |
205 | 205 |
| 206 LauncherItem GetItemByID(LauncherID id) { |
| 207 LauncherItems::const_iterator items = model_->ItemByID(id); |
| 208 return *items; |
| 209 } |
| 210 |
206 void CheckModelIDs( | 211 void CheckModelIDs( |
207 const std::vector<std::pair<LauncherID, views::View*> >& id_map) { | 212 const std::vector<std::pair<LauncherID, views::View*> >& id_map) { |
208 ASSERT_EQ(static_cast<int>(id_map.size()), test_api_->GetButtonCount()); | 213 ASSERT_EQ(static_cast<int>(id_map.size()), test_api_->GetButtonCount()); |
209 ASSERT_EQ(id_map.size(), model_->items().size()); | 214 ASSERT_EQ(id_map.size(), model_->items().size()); |
210 for (size_t i = 0; i < id_map.size(); ++i) { | 215 for (size_t i = 0; i < id_map.size(); ++i) { |
211 EXPECT_EQ(id_map[i].first, model_->items()[i].id); | 216 EXPECT_EQ(id_map[i].first, model_->items()[i].id); |
212 EXPECT_EQ(id_map[i].second, test_api_->GetButton(i)); | 217 EXPECT_EQ(id_map[i].second, test_api_->GetButton(i)); |
213 } | 218 } |
214 } | 219 } |
215 | 220 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 404 |
400 // Adding a launcher item cancels the drag and respects the order. | 405 // Adding a launcher item cancels the drag and respects the order. |
401 dragged_button = SimulateDrag(1, 3); | 406 dragged_button = SimulateDrag(1, 3); |
402 LauncherID new_id = AddAppShortcut(); | 407 LauncherID new_id = AddAppShortcut(); |
403 id_map.insert(id_map.begin() + 5, | 408 id_map.insert(id_map.begin() + 5, |
404 std::make_pair(new_id, test_api_->GetButton(5))); | 409 std::make_pair(new_id, test_api_->GetButton(5))); |
405 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 410 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
406 button_host->MouseReleasedOnButton(dragged_button, false); | 411 button_host->MouseReleasedOnButton(dragged_button, false); |
407 } | 412 } |
408 | 413 |
| 414 // Confirm that item status changes are reflected in the buttons. |
| 415 TEST_F(LauncherViewTest, LauncherItemStatus) { |
| 416 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, |
| 417 test_api_->GetButtonCount()); |
| 418 |
| 419 // Add tabbed browser. |
| 420 LauncherID last_added = AddTabbedBrowser(); |
| 421 LauncherItem item = GetItemByID(last_added); |
| 422 int index = model_->ItemIndexByID(last_added); |
| 423 internal::LauncherButton* button = GetButtonByID(last_added); |
| 424 ASSERT_EQ(internal::LauncherButton::STATE_RUNNING, button->state()); |
| 425 item.status = ash::STATUS_ACTIVE; |
| 426 model_->Set(index, item); |
| 427 ASSERT_EQ(internal::LauncherButton::STATE_ACTIVE, button->state()); |
| 428 item.status = ash::STATUS_ATTENTION; |
| 429 model_->Set(index, item); |
| 430 ASSERT_EQ(internal::LauncherButton::STATE_ATTENTION, button->state()); |
| 431 } |
| 432 |
409 } // namespace test | 433 } // namespace test |
410 } // namespace ash | 434 } // namespace ash |
OLD | NEW |