| 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/extensions/extension_sorting.h" | 5 #include "chrome/browser/extensions/extension_sorting.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "chrome/browser/extensions/extension_prefs_unittest.h" | 9 #include "chrome/browser/extensions/extension_prefs_unittest.h" |
| 10 #include "chrome/common/extensions/extension_manifest_constants.h" | 10 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 11 #include "sync/api/string_ordinal.h" | 11 #include "sync/api/string_ordinal.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 using extensions::Extension; | 14 using extensions::Extension; |
| 15 using extensions::Manifest; |
| 15 | 16 |
| 16 namespace keys = extension_manifest_keys; | 17 namespace keys = extension_manifest_keys; |
| 17 | 18 |
| 18 class ExtensionSortingTest : public extensions::ExtensionPrefsTest { | 19 class ExtensionSortingTest : public extensions::ExtensionPrefsTest { |
| 19 protected: | 20 protected: |
| 20 ExtensionSorting* extension_sorting() { | 21 ExtensionSorting* extension_sorting() { |
| 21 return prefs()->extension_sorting(); | 22 return prefs()->extension_sorting(); |
| 22 } | 23 } |
| 23 }; | 24 }; |
| 24 | 25 |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 public: | 621 public: |
| 621 ExtensionSortingPreinstalledAppsBase() { | 622 ExtensionSortingPreinstalledAppsBase() { |
| 622 DictionaryValue simple_dict; | 623 DictionaryValue simple_dict; |
| 623 simple_dict.SetString(keys::kVersion, "1.0.0.0"); | 624 simple_dict.SetString(keys::kVersion, "1.0.0.0"); |
| 624 simple_dict.SetString(keys::kName, "unused"); | 625 simple_dict.SetString(keys::kName, "unused"); |
| 625 simple_dict.SetString(keys::kApp, "true"); | 626 simple_dict.SetString(keys::kApp, "true"); |
| 626 simple_dict.SetString(keys::kLaunchLocalPath, "fake.html"); | 627 simple_dict.SetString(keys::kLaunchLocalPath, "fake.html"); |
| 627 | 628 |
| 628 std::string error; | 629 std::string error; |
| 629 app1_scoped_ = Extension::Create( | 630 app1_scoped_ = Extension::Create( |
| 630 prefs_.temp_dir().AppendASCII("app1_"), Extension::EXTERNAL_PREF, | 631 prefs_.temp_dir().AppendASCII("app1_"), Manifest::EXTERNAL_PREF, |
| 631 simple_dict, Extension::NO_FLAGS, &error); | 632 simple_dict, Extension::NO_FLAGS, &error); |
| 632 prefs()->OnExtensionInstalled(app1_scoped_.get(), | 633 prefs()->OnExtensionInstalled(app1_scoped_.get(), |
| 633 Extension::ENABLED, | 634 Extension::ENABLED, |
| 634 syncer::StringOrdinal()); | 635 syncer::StringOrdinal()); |
| 635 | 636 |
| 636 app2_scoped_ = Extension::Create( | 637 app2_scoped_ = Extension::Create( |
| 637 prefs_.temp_dir().AppendASCII("app2_"), Extension::EXTERNAL_PREF, | 638 prefs_.temp_dir().AppendASCII("app2_"), Manifest::EXTERNAL_PREF, |
| 638 simple_dict, Extension::NO_FLAGS, &error); | 639 simple_dict, Extension::NO_FLAGS, &error); |
| 639 prefs()->OnExtensionInstalled(app2_scoped_.get(), | 640 prefs()->OnExtensionInstalled(app2_scoped_.get(), |
| 640 Extension::ENABLED, | 641 Extension::ENABLED, |
| 641 syncer::StringOrdinal()); | 642 syncer::StringOrdinal()); |
| 642 | 643 |
| 643 app1_ = app1_scoped_.get(); | 644 app1_ = app1_scoped_.get(); |
| 644 app2_ = app2_scoped_.get(); | 645 app2_ = app2_scoped_.get(); |
| 645 } | 646 } |
| 646 virtual ~ExtensionSortingPreinstalledAppsBase() {} | 647 virtual ~ExtensionSortingPreinstalledAppsBase() {} |
| 647 | 648 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 protected: | 798 protected: |
| 798 scoped_refptr<Extension> CreateApp(const std::string& name) { | 799 scoped_refptr<Extension> CreateApp(const std::string& name) { |
| 799 DictionaryValue simple_dict; | 800 DictionaryValue simple_dict; |
| 800 simple_dict.SetString(keys::kVersion, "1.0.0.0"); | 801 simple_dict.SetString(keys::kVersion, "1.0.0.0"); |
| 801 simple_dict.SetString(keys::kName, name); | 802 simple_dict.SetString(keys::kName, name); |
| 802 simple_dict.SetString(keys::kApp, "true"); | 803 simple_dict.SetString(keys::kApp, "true"); |
| 803 simple_dict.SetString(keys::kLaunchLocalPath, "fake.html"); | 804 simple_dict.SetString(keys::kLaunchLocalPath, "fake.html"); |
| 804 | 805 |
| 805 std::string errors; | 806 std::string errors; |
| 806 scoped_refptr<Extension> app = Extension::Create( | 807 scoped_refptr<Extension> app = Extension::Create( |
| 807 prefs_.temp_dir().AppendASCII(name), Extension::EXTERNAL_PREF, | 808 prefs_.temp_dir().AppendASCII(name), Manifest::EXTERNAL_PREF, |
| 808 simple_dict, Extension::NO_FLAGS, &errors); | 809 simple_dict, Extension::NO_FLAGS, &errors); |
| 809 EXPECT_TRUE(app) << errors; | 810 EXPECT_TRUE(app) << errors; |
| 810 EXPECT_TRUE(Extension::IdIsValid(app->id())); | 811 EXPECT_TRUE(Extension::IdIsValid(app->id())); |
| 811 return app; | 812 return app; |
| 812 } | 813 } |
| 813 | 814 |
| 814 void InitDefaultOrdinals() { | 815 void InitDefaultOrdinals() { |
| 815 default_page_ordinal_ = | 816 default_page_ordinal_ = |
| 816 syncer::StringOrdinal::CreateInitialOrdinal().CreateAfter(); | 817 syncer::StringOrdinal::CreateInitialOrdinal().CreateAfter(); |
| 817 default_app_launch_ordinal_ = | 818 default_app_launch_ordinal_ = |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 extension_sorting->SetAppLaunchOrdinal(yet_another_app_->id(), | 945 extension_sorting->SetAppLaunchOrdinal(yet_another_app_->id(), |
| 945 default_app_launch_ordinal_); | 946 default_app_launch_ordinal_); |
| 946 } | 947 } |
| 947 | 948 |
| 948 private: | 949 private: |
| 949 scoped_refptr<Extension> other_app_; | 950 scoped_refptr<Extension> other_app_; |
| 950 scoped_refptr<Extension> yet_another_app_; | 951 scoped_refptr<Extension> yet_another_app_; |
| 951 }; | 952 }; |
| 952 TEST_F(ExtensionSortingDefaultOrdinalNoCollision, | 953 TEST_F(ExtensionSortingDefaultOrdinalNoCollision, |
| 953 ExtensionSortingDefaultOrdinalNoCollision) {} | 954 ExtensionSortingDefaultOrdinalNoCollision) {} |
| OLD | NEW |