| 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 "chrome/browser/memory/tab_manager.h" | 5 #include "chrome/browser/memory/tab_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/metrics/field_trial.h" |
| 13 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 14 #include "base/test/mock_entropy_provider.h" | 16 #include "base/test/mock_entropy_provider.h" |
| 15 #include "base/test/simple_test_tick_clock.h" | 17 #include "base/test/simple_test_tick_clock.h" |
| 16 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 17 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 18 #include "chrome/browser/memory/tab_manager_web_contents_data.h" | 20 #include "chrome/browser/memory/tab_manager_web_contents_data.h" |
| 19 #include "chrome/browser/memory/tab_stats.h" | 21 #include "chrome/browser/memory/tab_stats.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 22 #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h" | 24 #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h" |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 // Not setting the variation parameter. | 460 // Not setting the variation parameter. |
| 459 { | 461 { |
| 460 bool discard_once_value = tab_manager.CanOnlyDiscardOnce(); | 462 bool discard_once_value = tab_manager.CanOnlyDiscardOnce(); |
| 461 EXPECT_TRUE(discard_once_value); | 463 EXPECT_TRUE(discard_once_value); |
| 462 } | 464 } |
| 463 | 465 |
| 464 // Setting the variation parameter to true. | 466 // Setting the variation parameter to true. |
| 465 { | 467 { |
| 466 std::unique_ptr<base::FieldTrialList> field_trial_list_; | 468 std::unique_ptr<base::FieldTrialList> field_trial_list_; |
| 467 field_trial_list_.reset( | 469 field_trial_list_.reset( |
| 468 new base::FieldTrialList(new base::MockEntropyProvider())); | 470 new base::FieldTrialList( |
| 471 base::MakeUnique<base::MockEntropyProvider>())); |
| 469 variations::testing::ClearAllVariationParams(); | 472 variations::testing::ClearAllVariationParams(); |
| 470 | 473 |
| 471 std::map<std::string, std::string> params; | 474 std::map<std::string, std::string> params; |
| 472 params["AllowMultipleDiscards"] = "true"; | 475 params["AllowMultipleDiscards"] = "true"; |
| 473 ASSERT_TRUE(variations::AssociateVariationParams(kTrialName, "A", params)); | 476 ASSERT_TRUE(variations::AssociateVariationParams(kTrialName, "A", params)); |
| 474 base::FieldTrialList::CreateFieldTrial(kTrialName, "A"); | 477 base::FieldTrialList::CreateFieldTrial(kTrialName, "A"); |
| 475 | 478 |
| 476 bool discard_once_value = tab_manager.CanOnlyDiscardOnce(); | 479 bool discard_once_value = tab_manager.CanOnlyDiscardOnce(); |
| 477 EXPECT_FALSE(discard_once_value); | 480 EXPECT_FALSE(discard_once_value); |
| 478 } | 481 } |
| 479 | 482 |
| 480 // Setting the variation parameter to something else. | 483 // Setting the variation parameter to something else. |
| 481 { | 484 { |
| 482 std::unique_ptr<base::FieldTrialList> field_trial_list_; | 485 std::unique_ptr<base::FieldTrialList> field_trial_list_; |
| 483 field_trial_list_.reset( | 486 field_trial_list_.reset( |
| 484 new base::FieldTrialList(new base::MockEntropyProvider())); | 487 new base::FieldTrialList( |
| 488 base::MakeUnique<base::MockEntropyProvider>())); |
| 485 variations::testing::ClearAllVariationParams(); | 489 variations::testing::ClearAllVariationParams(); |
| 486 | 490 |
| 487 std::map<std::string, std::string> params; | 491 std::map<std::string, std::string> params; |
| 488 params["AllowMultipleDiscards"] = "somethingElse"; | 492 params["AllowMultipleDiscards"] = "somethingElse"; |
| 489 ASSERT_TRUE(variations::AssociateVariationParams(kTrialName, "B", params)); | 493 ASSERT_TRUE(variations::AssociateVariationParams(kTrialName, "B", params)); |
| 490 base::FieldTrialList::CreateFieldTrial(kTrialName, "B"); | 494 base::FieldTrialList::CreateFieldTrial(kTrialName, "B"); |
| 491 | 495 |
| 492 bool discard_once_value = tab_manager.CanOnlyDiscardOnce(); | 496 bool discard_once_value = tab_manager.CanOnlyDiscardOnce(); |
| 493 EXPECT_TRUE(discard_once_value); | 497 EXPECT_TRUE(discard_once_value); |
| 494 } | 498 } |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 EXPECT_EQ(0u, task_runner->size()); | 665 EXPECT_EQ(0u, task_runner->size()); |
| 662 EXPECT_EQ(0u, tm.notified_renderers_.size()); | 666 EXPECT_EQ(0u, tm.notified_renderers_.size()); |
| 663 | 667 |
| 664 | 668 |
| 665 // Clean up the tabstrip. | 669 // Clean up the tabstrip. |
| 666 tabstrip.CloseAllTabs(); | 670 tabstrip.CloseAllTabs(); |
| 667 ASSERT_TRUE(tabstrip.empty()); | 671 ASSERT_TRUE(tabstrip.empty()); |
| 668 } | 672 } |
| 669 | 673 |
| 670 } // namespace memory | 674 } // namespace memory |
| OLD | NEW |