| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
| 10 #include "base/scoped_vector.h" |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 11 #include "chrome/browser/extensions/extension_menu_manager.h" | 12 #include "chrome/browser/extensions/extension_menu_manager.h" |
| 12 #include "chrome/browser/extensions/extension_message_service.h" | 13 #include "chrome/browser/extensions/extension_message_service.h" |
| 13 #include "chrome/browser/extensions/test_extension_prefs.h" | 14 #include "chrome/browser/extensions/test_extension_prefs.h" |
| 14 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
| 15 #include "chrome/common/extensions/extension.h" | 16 #include "chrome/common/extensions/extension.h" |
| 16 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
| 17 #include "chrome/common/notification_service.h" | 18 #include "chrome/common/notification_service.h" |
| 18 #include "chrome/test/testing_profile.h" | 19 #include "chrome/test/testing_profile.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 36 ExtensionMenuItem::Type type = ExtensionMenuItem::NORMAL; | 37 ExtensionMenuItem::Type type = ExtensionMenuItem::NORMAL; |
| 37 ExtensionMenuItem::ContextList contexts(ExtensionMenuItem::ALL); | 38 ExtensionMenuItem::ContextList contexts(ExtensionMenuItem::ALL); |
| 38 ExtensionMenuItem::ContextList enabled_contexts = contexts; | 39 ExtensionMenuItem::ContextList enabled_contexts = contexts; |
| 39 return new ExtensionMenuItem(extension->id(), "test", false, type, contexts, | 40 return new ExtensionMenuItem(extension->id(), "test", false, type, contexts, |
| 40 enabled_contexts); | 41 enabled_contexts); |
| 41 } | 42 } |
| 42 | 43 |
| 43 // Creates and returns a test Extension. The caller does *not* own the return | 44 // Creates and returns a test Extension. The caller does *not* own the return |
| 44 // value. | 45 // value. |
| 45 Extension* AddExtension(std::string name) { | 46 Extension* AddExtension(std::string name) { |
| 46 return prefs_.AddExtension(name); | 47 Extension* extension = prefs_.AddExtension(name); |
| 48 extensions_.push_back(extension); |
| 49 return extension; |
| 47 } | 50 } |
| 48 | 51 |
| 49 protected: | 52 protected: |
| 50 ExtensionMenuManager manager_; | 53 ExtensionMenuManager manager_; |
| 54 ScopedVector<Extension> extensions_; |
| 51 TestExtensionPrefs prefs_; | 55 TestExtensionPrefs prefs_; |
| 52 | 56 |
| 53 private: | 57 private: |
| 54 DISALLOW_COPY_AND_ASSIGN(ExtensionMenuManagerTest); | 58 DISALLOW_COPY_AND_ASSIGN(ExtensionMenuManagerTest); |
| 55 }; | 59 }; |
| 56 | 60 |
| 57 // Tests adding, getting, and removing items. | 61 // Tests adding, getting, and removing items. |
| 58 TEST_F(ExtensionMenuManagerTest, AddGetRemoveItems) { | 62 TEST_F(ExtensionMenuManagerTest, AddGetRemoveItems) { |
| 59 Extension* extension = AddExtension("test"); | 63 Extension* extension = AddExtension("test"); |
| 60 | 64 |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 ASSERT_EQ(params.page_url.spec(), tmp); | 399 ASSERT_EQ(params.page_url.spec(), tmp); |
| 396 | 400 |
| 397 std::wstring wide_tmp; | 401 std::wstring wide_tmp; |
| 398 ASSERT_TRUE(info->GetString(L"selectionText", &wide_tmp)); | 402 ASSERT_TRUE(info->GetString(L"selectionText", &wide_tmp)); |
| 399 ASSERT_EQ(params.selection_text, wide_tmp); | 403 ASSERT_EQ(params.selection_text, wide_tmp); |
| 400 | 404 |
| 401 bool bool_tmp = true; | 405 bool bool_tmp = true; |
| 402 ASSERT_TRUE(info->GetBoolean(L"editable", &bool_tmp)); | 406 ASSERT_TRUE(info->GetBoolean(L"editable", &bool_tmp)); |
| 403 ASSERT_EQ(params.is_editable, bool_tmp); | 407 ASSERT_EQ(params.is_editable, bool_tmp); |
| 404 } | 408 } |
| OLD | NEW |