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

Side by Side Diff: chromeos/ime/component_extension_ime_manager_unittest.cc

Issue 389913002: Moving IME manifests to chrome resources. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "chromeos/ime/component_extension_ime_manager.h" 6 #include "chromeos/ime/component_extension_ime_manager.h"
7 #include "chromeos/ime/extension_ime_util.h" 7 #include "chromeos/ime/extension_ime_util.h"
8 #include "chromeos/ime/mock_component_extension_ime_manager_delegate.h" 8 #include "chromeos/ime/mock_component_extension_ime_manager_delegate.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace chromeos { 11 namespace chromeos {
12 namespace input_method { 12 namespace input_method {
13 13
14 namespace { 14 namespace {
15 15
16 class ComponentExtensionIMEManagerTest : 16 class ComponentExtensionIMEManagerTest : public testing::Test {
17 public testing::Test,
18 public ComponentExtensionIMEManager::Observer {
19 public: 17 public:
20 ComponentExtensionIMEManagerTest() 18 ComponentExtensionIMEManagerTest() : mock_delegate_(NULL) {}
21 : mock_delegate_(NULL),
22 on_initialized_callcount_(0) {
23 }
24 19
25 virtual void SetUp() { 20 virtual void SetUp() {
26 ime_list_.clear(); 21 ime_list_.clear();
27 22
28 ComponentExtensionIME ext1; 23 ComponentExtensionIME ext1;
29 ext1.id = "ext1_id"; 24 ext1.id = "ext1_id";
30 ext1.description = "ext1_description"; 25 ext1.description = "ext1_description";
31 ext1.options_page_url = 26 ext1.options_page_url =
32 GURL("chrome-extension://" + ext1.id + "/options.html"); 27 GURL("chrome-extension://" + ext1.id + "/options.html");
33 ext1.path = base::FilePath("ext1_file_path"); 28 ext1.path = base::FilePath("ext1_file_path");
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 ext3_engine3.display_name = "ext3_engine3_display_name"; 104 ext3_engine3.display_name = "ext3_engine3_display_name";
110 ext3_engine3.language_codes.push_back("en"); 105 ext3_engine3.language_codes.push_back("en");
111 ext3_engine3.layouts.push_back("us"); 106 ext3_engine3.layouts.push_back("us");
112 ext3.engines.push_back(ext3_engine3); 107 ext3.engines.push_back(ext3_engine3);
113 108
114 ime_list_.push_back(ext3); 109 ime_list_.push_back(ext3);
115 110
116 mock_delegate_ = new MockComponentExtIMEManagerDelegate(); 111 mock_delegate_ = new MockComponentExtIMEManagerDelegate();
117 mock_delegate_->set_ime_list(ime_list_); 112 mock_delegate_->set_ime_list(ime_list_);
118 component_ext_mgr_.reset(new ComponentExtensionIMEManager()); 113 component_ext_mgr_.reset(new ComponentExtensionIMEManager());
119 component_ext_mgr_->AddObserver(this);
120 EXPECT_FALSE(component_ext_mgr_->IsInitialized());
121 component_ext_mgr_->Initialize( 114 component_ext_mgr_->Initialize(
122 scoped_ptr<ComponentExtensionIMEManagerDelegate>( 115 scoped_ptr<ComponentExtensionIMEManagerDelegate>(
123 mock_delegate_).Pass()); 116 mock_delegate_).Pass());
124 EXPECT_TRUE(component_ext_mgr_->IsInitialized());
125 component_ext_mgr_->NotifyInitialized();
126 } 117 }
127 118
128 virtual void TearDown() { 119 virtual void TearDown() {
129 EXPECT_EQ(1, on_initialized_callcount_);
130 component_ext_mgr_->RemoveObserver(this);
131 } 120 }
132 121
133 protected: 122 protected:
134 MockComponentExtIMEManagerDelegate* mock_delegate_; 123 MockComponentExtIMEManagerDelegate* mock_delegate_;
135 scoped_ptr<ComponentExtensionIMEManager> component_ext_mgr_; 124 scoped_ptr<ComponentExtensionIMEManager> component_ext_mgr_;
136 std::vector<ComponentExtensionIME> ime_list_; 125 std::vector<ComponentExtensionIME> ime_list_;
137 126
138 private: 127 private:
139 virtual void OnImeComponentExtensionInitialized() OVERRIDE {
140 ++on_initialized_callcount_;
141 }
142
143 int on_initialized_callcount_;
144 128
145 DISALLOW_COPY_AND_ASSIGN(ComponentExtensionIMEManagerTest); 129 DISALLOW_COPY_AND_ASSIGN(ComponentExtensionIMEManagerTest);
146 }; 130 };
147 131
148 TEST_F(ComponentExtensionIMEManagerTest, LoadComponentExtensionIMETest) { 132 TEST_F(ComponentExtensionIMEManagerTest, LoadComponentExtensionIMETest) {
149 for (size_t i = 0; i < ime_list_.size(); ++i) { 133 for (size_t i = 0; i < ime_list_.size(); ++i) {
150 for (size_t j = 0; j < ime_list_[i].engines.size(); ++j) { 134 for (size_t j = 0; j < ime_list_[i].engines.size(); ++j) {
151 const std::string input_method_id = 135 const std::string input_method_id =
152 extension_ime_util::GetComponentInputMethodID( 136 extension_ime_util::GetComponentInputMethodID(
153 ime_list_[i].id, 137 ime_list_[i].id,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 for (size_t i = 0; i < ime_list_.size(); ++i) { 230 for (size_t i = 0; i < ime_list_.size(); ++i) {
247 total_ime_size += ime_list_[i].engines.size(); 231 total_ime_size += ime_list_[i].engines.size();
248 } 232 }
249 EXPECT_EQ(total_ime_size, descriptors.size()); 233 EXPECT_EQ(total_ime_size, descriptors.size());
250 } 234 }
251 235
252 } // namespace 236 } // namespace
253 237
254 } // namespace input_method 238 } // namespace input_method
255 } // namespace chromeos 239 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698