| Index: chrome/browser/extensions/extension_prefs_unittest.cc
|
| diff --git a/chrome/browser/extensions/extension_prefs_unittest.cc b/chrome/browser/extensions/extension_prefs_unittest.cc
|
| index 3d937d8c5d73291d70b54ca2db64f90fc29eebb5..7b259ea2e2b53fd89f122696bffad1853f80ba66 100644
|
| --- a/chrome/browser/extensions/extension_prefs_unittest.cc
|
| +++ b/chrome/browser/extensions/extension_prefs_unittest.cc
|
| @@ -15,6 +15,7 @@
|
| #include "chrome/common/chrome_paths.h"
|
| #include "chrome/common/extensions/extension_constants.h"
|
| #include "chrome/common/extensions/extension_permission_set.h"
|
| +#include "chrome/common/string_ordinal.h"
|
| #include "content/public/browser/notification_details.h"
|
| #include "content/public/browser/notification_source.h"
|
| #include "content/test/notification_observer_mock.h"
|
| @@ -654,7 +655,8 @@ class ExtensionPrefsOnExtensionInstalled : public ExtensionPrefsTest {
|
| extension_ = prefs_.AddExtension("on_extension_installed");
|
| EXPECT_FALSE(prefs()->IsExtensionDisabled(extension_->id()));
|
| prefs()->OnExtensionInstalled(
|
| - extension_.get(), Extension::DISABLED, false, -1);
|
| + extension_.get(), Extension::DISABLED, false,
|
| + StringOrdinal());
|
| }
|
|
|
| virtual void Verify() {
|
| @@ -671,31 +673,44 @@ class ExtensionPrefsAppLaunchIndex : public ExtensionPrefsTest {
|
| public:
|
| virtual void Initialize() {
|
| // No extensions yet.
|
| - EXPECT_EQ(0, prefs()->GetNextAppLaunchIndex(0));
|
| + StringOrdinal page = StringOrdinal::CreateValidOrdinal();
|
| + EXPECT_TRUE(StringOrdinal::CreateValidOrdinal().Equal(
|
| + prefs()->GetNextAppLaunchIndex(page)));
|
|
|
| extension_ = prefs_.AddApp("on_extension_installed");
|
| EXPECT_FALSE(prefs()->IsExtensionDisabled(extension_->id()));
|
| prefs()->OnExtensionInstalled(extension_.get(), Extension::ENABLED,
|
| - false, -1);
|
| + false, StringOrdinal());
|
| }
|
|
|
| virtual void Verify() {
|
| - int launch_index = prefs()->GetAppLaunchIndex(extension_->id());
|
| - // Extension should have been assigned a launch index > 0.
|
| - EXPECT_GT(launch_index, 0);
|
| - EXPECT_EQ(launch_index + 1, prefs()->GetNextAppLaunchIndex(0));
|
| - // Set a new launch index of one higher and verify.
|
| + StringOrdinal launch_index = prefs()->GetAppLaunchIndex(extension_->id());
|
| + StringOrdinal page_index = StringOrdinal::CreateValidOrdinal();
|
| +
|
| + // Extension should have been assigned a valid StringOrdinal.
|
| + EXPECT_TRUE(launch_index.IsValid());
|
| + EXPECT_TRUE(launch_index.LessThan(
|
| + prefs()->GetNextAppLaunchIndex(page_index)));
|
| + // Set a new launch index of and verify it comes after.
|
| prefs()->SetAppLaunchIndex(extension_->id(),
|
| - prefs()->GetNextAppLaunchIndex(0));
|
| - int new_launch_index = prefs()->GetAppLaunchIndex(extension_->id());
|
| - EXPECT_EQ(launch_index + 1, new_launch_index);
|
| + prefs()->GetNextAppLaunchIndex(page_index));
|
| + StringOrdinal new_launch_index =
|
| + prefs()->GetAppLaunchIndex(extension_->id());
|
| + EXPECT_TRUE(launch_index.LessThan(new_launch_index));
|
|
|
| - // This extension doesn't exist, so it should return -1.
|
| - EXPECT_EQ(-1, prefs()->GetAppLaunchIndex("foo"));
|
| + // This extension doesn't exist, so it should return an invalid
|
| + // StringOrdinal.
|
| + StringOrdinal invalid_app_launch_index = prefs()->GetAppLaunchIndex("foo");
|
| + EXPECT_FALSE(invalid_app_launch_index.IsValid());
|
| + EXPECT_EQ(-1, prefs()->PageIndexAsInteger(invalid_app_launch_index));
|
|
|
| // The second page doesn't have any apps so its next launch index should
|
| - // still be 0.
|
| - EXPECT_EQ(prefs()->GetNextAppLaunchIndex(1), 0);
|
| + // be the first launch index.
|
| + StringOrdinal next_page = page_index.CreateAfter();
|
| + StringOrdinal next_page_app_launch_index = prefs()->GetNextAppLaunchIndex(
|
| + next_page);
|
| + EXPECT_TRUE(next_page_app_launch_index.Equal(
|
| + prefs()->CreateFirstAppLaunchIndex(next_page)));
|
| }
|
|
|
| private:
|
| @@ -707,26 +722,33 @@ class ExtensionPrefsPageIndex : public ExtensionPrefsTest {
|
| public:
|
| virtual void Initialize() {
|
| extension_ = prefs_.AddApp("page_index");
|
| - // Install to page 3 (index 2).
|
| + // Install with a page preference.
|
| + StringOrdinal page = StringOrdinal::CreateValidOrdinal();
|
| prefs()->OnExtensionInstalled(extension_.get(), Extension::ENABLED,
|
| - false, 2);
|
| - EXPECT_EQ(2, prefs()->GetPageIndex(extension_->id()));
|
| + false, page);
|
| + EXPECT_TRUE(page.Equal(prefs()->GetPageIndex(extension_->id())));
|
| + EXPECT_EQ(0, prefs()->PageIndexAsInteger(page));
|
|
|
| scoped_refptr<Extension> extension2 = prefs_.AddApp("page_index_2");
|
| // Install without any page preference.
|
| prefs()->OnExtensionInstalled(extension_.get(), Extension::ENABLED,
|
| - false, -1);
|
| - EXPECT_EQ(0, prefs()->GetPageIndex(extension_->id()));
|
| + false, StringOrdinal());
|
| + EXPECT_TRUE(prefs()->GetPageIndex(extension_->id()).IsValid());
|
| }
|
|
|
| virtual void Verify() {
|
| + StringOrdinal old_page = prefs()->GetPageIndex(extension_->id());
|
| + StringOrdinal new_page = old_page.CreateAfter();
|
| +
|
| // Set the page index.
|
| - prefs()->SetPageIndex(extension_->id(), 1);
|
| + prefs()->SetPageIndex(extension_->id(), new_page);
|
| // Verify the page index.
|
| - EXPECT_EQ(1, prefs()->GetPageIndex(extension_->id()));
|
| + EXPECT_TRUE(new_page.Equal(prefs()->GetPageIndex(extension_->id())));
|
| + EXPECT_EQ(1, prefs()->PageIndexAsInteger(new_page));
|
|
|
| - // This extension doesn't exist, so it should return -1.
|
| - EXPECT_EQ(-1, prefs()->GetPageIndex("foo"));
|
| + // This extension doesn't exist, so it should return an invalid
|
| + // StringOrdinal.
|
| + EXPECT_FALSE(prefs()->GetPageIndex("foo").IsValid());
|
| }
|
|
|
| private:
|
| @@ -740,12 +762,12 @@ class ExtensionPrefsAppLocation : public ExtensionPrefsTest {
|
| extension_ = prefs_.AddExtension("not_an_app");
|
| // Non-apps should not have any app launch index or page index.
|
| prefs()->OnExtensionInstalled(extension_.get(), Extension::ENABLED,
|
| - false, 0);
|
| + false, StringOrdinal::CreateValidOrdinal());
|
| }
|
|
|
| virtual void Verify() {
|
| - EXPECT_EQ(-1, prefs()->GetAppLaunchIndex(extension_->id()));
|
| - EXPECT_EQ(-1, prefs()->GetPageIndex(extension_->id()));
|
| + EXPECT_FALSE(prefs()->GetAppLaunchIndex(extension_->id()).IsValid());
|
| + EXPECT_FALSE(prefs()->GetPageIndex(extension_->id()).IsValid());
|
| }
|
|
|
| private:
|
| @@ -759,7 +781,7 @@ class ExtensionPrefsAppDraggedByUser : public ExtensionPrefsTest {
|
| extension_ = prefs_.AddExtension("on_extension_installed");
|
| EXPECT_FALSE(prefs()->WasAppDraggedByUser(extension_->id()));
|
| prefs()->OnExtensionInstalled(extension_.get(), Extension::ENABLED,
|
| - false, -1);
|
| + false, StringOrdinal());
|
| }
|
|
|
| virtual void Verify() {
|
| @@ -909,7 +931,8 @@ class ExtensionPrefsPreferencesBase : public ExtensionPrefsTest {
|
| Extension* extensions[] = {ext1_, ext2_, ext3_};
|
| for (int i = 0; i < 3; ++i) {
|
| if (ext == extensions[i] && !installed[i]) {
|
| - prefs()->OnExtensionInstalled(ext, Extension::ENABLED, false, -1);
|
| + prefs()->OnExtensionInstalled(ext, Extension::ENABLED,
|
| + false, StringOrdinal());
|
| installed[i] = true;
|
| break;
|
| }
|
|
|