| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/toolbar/toolbar_actions_bar.h" | 5 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 // Verifies that the toolbar order matches for the given |actions_bar|. If the | 33 // Verifies that the toolbar order matches for the given |actions_bar|. If the |
| 34 // order matches, the return value is empty; otherwise, it contains the error. | 34 // order matches, the return value is empty; otherwise, it contains the error. |
| 35 std::string VerifyToolbarOrderForBar( | 35 std::string VerifyToolbarOrderForBar( |
| 36 const ToolbarActionsBar* actions_bar, | 36 const ToolbarActionsBar* actions_bar, |
| 37 BrowserActionTestUtil* browser_action_test_util, | 37 BrowserActionTestUtil* browser_action_test_util, |
| 38 const char* expected_names[], | 38 const char* expected_names[], |
| 39 size_t total_size, | 39 size_t total_size, |
| 40 size_t visible_count) { | 40 size_t visible_count) { |
| 41 const std::vector<ToolbarActionViewController*>& toolbar_actions = | 41 const std::vector<ToolbarActionViewController*>& toolbar_actions = |
| 42 actions_bar->toolbar_actions(); | 42 actions_bar->toolbar_actions_unordered(); |
| 43 // If the total size is wrong, we risk segfaulting by continuing. Abort now. | 43 // If the total size is wrong, we risk segfaulting by continuing. Abort now. |
| 44 if (total_size != toolbar_actions.size()) { | 44 if (total_size != toolbar_actions.size()) { |
| 45 return base::StringPrintf("Incorrect action count: expected %d, found %d", | 45 return base::StringPrintf("Incorrect action count: expected %d, found %d", |
| 46 static_cast<int>(total_size), | 46 static_cast<int>(total_size), |
| 47 static_cast<int>(toolbar_actions.size())); | 47 static_cast<int>(toolbar_actions.size())); |
| 48 } | 48 } |
| 49 | 49 |
| 50 // Check that the ToolbarActionsBar matches the expected state. | 50 // Check that the ToolbarActionsBar matches the expected state. |
| 51 std::string error; | 51 std::string error; |
| 52 for (size_t i = 0; i < total_size; ++i) { | 52 for (size_t i = 0; i < total_size; ++i) { |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 const char kExtension0[] = "extension 0"; | 388 const char kExtension0[] = "extension 0"; |
| 389 const char kExtension1[] = "extension 1"; | 389 const char kExtension1[] = "extension 1"; |
| 390 const char kExtension2[] = "extension 2"; | 390 const char kExtension2[] = "extension 2"; |
| 391 { | 391 { |
| 392 // The order should start as 0, 1, 2. | 392 // The order should start as 0, 1, 2. |
| 393 const char* expected_names[] = { kExtension0, kExtension1, kExtension2 }; | 393 const char* expected_names[] = { kExtension0, kExtension1, kExtension2 }; |
| 394 EXPECT_TRUE(VerifyToolbarOrder(expected_names, 3u, 3u)); | 394 EXPECT_TRUE(VerifyToolbarOrder(expected_names, 3u, 3u)); |
| 395 } | 395 } |
| 396 | 396 |
| 397 extensions::ExtensionIdList new_order; | 397 extensions::ExtensionIdList new_order; |
| 398 new_order.push_back(toolbar_actions_bar()->toolbar_actions()[1]->GetId()); | 398 new_order.push_back(toolbar_actions_bar()->toolbar_actions_unordered()[1]-> |
| 399 new_order.push_back(toolbar_actions_bar()->toolbar_actions()[2]->GetId()); | 399 GetId()); |
| 400 new_order.push_back(toolbar_actions_bar()->toolbar_actions_unordered()[2]-> |
| 401 GetId()); |
| 400 extensions::ExtensionPrefs::Get(profile())->SetToolbarOrder(new_order); | 402 extensions::ExtensionPrefs::Get(profile())->SetToolbarOrder(new_order); |
| 401 | 403 |
| 402 { | 404 { |
| 403 // The order should now reflect the prefs, and be 1, 2, 0. | 405 // The order should now reflect the prefs, and be 1, 2, 0. |
| 404 const char* expected_names[] = { kExtension1, kExtension2, kExtension0 }; | 406 const char* expected_names[] = { kExtension1, kExtension2, kExtension0 }; |
| 405 EXPECT_TRUE(VerifyToolbarOrder(expected_names, 3u, 3u)); | 407 EXPECT_TRUE(VerifyToolbarOrder(expected_names, 3u, 3u)); |
| 406 } | 408 } |
| 407 } | 409 } |
| 408 | 410 |
| 409 class ToolbarActionsBarRedesignUnitTest : public ToolbarActionsBarUnitTest { | 411 class ToolbarActionsBarRedesignUnitTest : public ToolbarActionsBarUnitTest { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE); | 459 ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE); |
| 458 EXPECT_FALSE( | 460 EXPECT_FALSE( |
| 459 ExtensionToolbarIconSurfacingBubbleDelegate::ShouldShowForProfile( | 461 ExtensionToolbarIconSurfacingBubbleDelegate::ShouldShowForProfile( |
| 460 profile())); | 462 profile())); |
| 461 base::Time one_week_ago = base::Time::Now() - base::TimeDelta::FromDays(7); | 463 base::Time one_week_ago = base::Time::Now() - base::TimeDelta::FromDays(7); |
| 462 prefs->SetInt64(prefs::kToolbarIconSurfacingBubbleLastShowTime, | 464 prefs->SetInt64(prefs::kToolbarIconSurfacingBubbleLastShowTime, |
| 463 one_week_ago.ToInternalValue()); | 465 one_week_ago.ToInternalValue()); |
| 464 EXPECT_TRUE( | 466 EXPECT_TRUE( |
| 465 prefs->GetBoolean(prefs::kToolbarIconSurfacingBubbleAcknowledged)); | 467 prefs->GetBoolean(prefs::kToolbarIconSurfacingBubbleAcknowledged)); |
| 466 } | 468 } |
| OLD | NEW |