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

Side by Side Diff: chrome/browser/extensions/extension_sorting_unittest.cc

Issue 10105019: Merge 132468 - [NTP4] Fix empty apps page crash. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1084/src/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/extension_sorting.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/extensions/extension_prefs_unittest.h" 5 #include "chrome/browser/extensions/extension_prefs_unittest.h"
6 #include "chrome/browser/extensions/extension_sorting.h" 6 #include "chrome/browser/extensions/extension_sorting.h"
7 #include "chrome/common/extensions/extension_manifest_constants.h" 7 #include "chrome/common/extensions/extension_manifest_constants.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace keys = extension_manifest_keys; 10 namespace keys = extension_manifest_keys;
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 max = extension_sorting->GetMinOrMaxAppLaunchOrdinalsOnPage( 678 max = extension_sorting->GetMinOrMaxAppLaunchOrdinalsOnPage(
679 empty_page, 679 empty_page,
680 ExtensionSorting::MAX_ORDINAL); 680 ExtensionSorting::MAX_ORDINAL);
681 EXPECT_FALSE(min.IsValid()); 681 EXPECT_FALSE(min.IsValid());
682 EXPECT_FALSE(max.IsValid()); 682 EXPECT_FALSE(max.IsValid());
683 } 683 }
684 }; 684 };
685 TEST_F(ExtensionSortingGetMinOrMaxAppLaunchOrdinalsOnPage, 685 TEST_F(ExtensionSortingGetMinOrMaxAppLaunchOrdinalsOnPage,
686 ExtensionSortingGetMinOrMaxAppLaunchOrdinalsOnPage) {} 686 ExtensionSortingGetMinOrMaxAppLaunchOrdinalsOnPage) {}
687 687
688 // Make sure that empty pages aren't removes from the integer to ordinal 688 // Make sure that empty pages aren't removed from the integer to ordinal
689 // mapping. See http://www.crbug.com/109802 for details. 689 // mapping. See http://www.crbug.com/109802 for details.
690 class ExtensionSortingKeepEmptyStringOrdinalPages : 690 class ExtensionSortingKeepEmptyStringOrdinalPages :
691 public ExtensionSortingPreinstalledAppsBase { 691 public ExtensionSortingPreinstalledAppsBase {
692 public: 692 public:
693 ExtensionSortingKeepEmptyStringOrdinalPages() {} 693 ExtensionSortingKeepEmptyStringOrdinalPages() {}
694 virtual ~ExtensionSortingKeepEmptyStringOrdinalPages() {} 694 virtual ~ExtensionSortingKeepEmptyStringOrdinalPages() {}
695 695
696 virtual void Initialize() { 696 virtual void Initialize() {
697 ExtensionSorting* extension_sorting = prefs()->extension_sorting(); 697 ExtensionSorting* extension_sorting = prefs()->extension_sorting();
698 698
(...skipping 19 matching lines...) Expand all
718 EXPECT_EQ(2, extension_sorting->PageStringOrdinalAsInteger(last_page_)); 718 EXPECT_EQ(2, extension_sorting->PageStringOrdinalAsInteger(last_page_));
719 EXPECT_TRUE( 719 EXPECT_TRUE(
720 last_page_.Equal(extension_sorting->PageIntegerAsStringOrdinal(2))); 720 last_page_.Equal(extension_sorting->PageIntegerAsStringOrdinal(2)));
721 } 721 }
722 722
723 private: 723 private:
724 StringOrdinal last_page_; 724 StringOrdinal last_page_;
725 }; 725 };
726 TEST_F(ExtensionSortingKeepEmptyStringOrdinalPages, 726 TEST_F(ExtensionSortingKeepEmptyStringOrdinalPages,
727 ExtensionSortingKeepEmptyStringOrdinalPages) {} 727 ExtensionSortingKeepEmptyStringOrdinalPages) {}
728
729 class ExtensionSortingMakesFillerOrdinals :
730 public ExtensionSortingPreinstalledAppsBase {
731 public:
732 ExtensionSortingMakesFillerOrdinals() {}
733 virtual ~ExtensionSortingMakesFillerOrdinals() {}
734
735 virtual void Initialize() {
736 ExtensionSorting* extension_sorting = prefs()->extension_sorting();
737
738 StringOrdinal first_page = StringOrdinal::CreateInitialOrdinal();
739 extension_sorting->SetPageOrdinal(app1_->id(), first_page);
740 EXPECT_EQ(0, extension_sorting->PageStringOrdinalAsInteger(first_page));
741 }
742 virtual void Verify() {
743 ExtensionSorting* extension_sorting = prefs()->extension_sorting();
744
745 // Because the UI can add an unlimited number of empty pages without an app
746 // on them, this test simulates dropping of an app on the 1st and 4th empty
747 // pages (3rd and 6th pages by index) to ensure we don't crash and that
748 // filler ordinals are created as needed. See: http://crbug.com/122214
749 StringOrdinal page_three = extension_sorting->PageIntegerAsStringOrdinal(2);
750 extension_sorting->SetPageOrdinal(app1_->id(), page_three);
751 EXPECT_EQ(2, extension_sorting->PageStringOrdinalAsInteger(page_three));
752
753 StringOrdinal page_six = extension_sorting->PageIntegerAsStringOrdinal(5);
754 extension_sorting->SetPageOrdinal(app1_->id(), page_six);
755 EXPECT_EQ(5, extension_sorting->PageStringOrdinalAsInteger(page_six));
756 }
757 };
758 TEST_F(ExtensionSortingMakesFillerOrdinals,
759 ExtensionSortingMakesFillerOrdinals) {}
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_sorting.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698