Codebase list mozc / 4ccb3a8
Stop using PackedDataManager in unit tests This CL eliminates the use of PackedDataManager except in Chrome OS. BUG= TEST= REF_BUG=26841123 REF_CL=117309545 REF_TIME=2016-03-16T13:47:37+09:00 REF_TIME_RAW=1458103657 +0900 Noriyuki Takahashi 8 years ago
9 changed file(s) with 13 addition(s) and 117 deletion(s). Raw diff Collapse all Expand all
173173 '../../config/config.gyp:config_handler',
174174 '../../dictionary/dictionary_base.gyp:user_dictionary',
175175 '../../dictionary/dictionary_base.gyp:user_pos',
176 '../../engine/engine.gyp:packed_engine_factory',
176177 '../../net/net.gyp:http_client',
177178 '../../net/net.gyp:json_util',
178179 '../../protocol/protocol.gyp:commands_proto',
5454 #include "data_manager/packed/packed_data_manager.h"
5555 #include "dictionary/user_dictionary_util.h"
5656 #include "dictionary/user_pos.h"
57 #include "engine/engine_factory.h"
57 #include "engine/packed_engine_factory.h"
5858 #include "net/http_client.h"
5959 #include "net/http_client_pepper.h"
6060 #include "net/json_util.h"
201201 user_pos_.reset(dictionary::UserPOS::CreateFromDataManager(
202202 *packed::PackedDataManager::GetUserPosManager()));
203203
204 engine_.reset(mozc::EngineFactory::Create());
204 engine_.reset(mozc::PackedEngineFactory::Create());
205205 handler_.reset(new SessionHandler(engine_.get()));
206206
207207 #ifdef GOOGLE_JAPANESE_INPUT_BUILD
4242 #include "protocol/config.pb.h"
4343 #include "request/conversion_request.h"
4444 #include "testing/base/public/gunit.h"
45
46 #ifdef MOZC_USE_PACKED_DICTIONARY
47 #ifdef MOZC_BUILD
48 #include "data_manager/packed/packed_data_oss.h"
49 #endif // MOZC_BUILD
50
51 #include "data_manager/packed/packed_data_manager.h"
52 #endif // MOZC_USE_PACKED_DICTIONARY
53
54 DECLARE_string(test_srcdir);
55 DECLARE_string(test_tmpdir);
45 #include "testing/base/public/mozctest.h"
5646
5747 namespace mozc {
5848
6353 using mozc::config::ConfigHandler;
6454
6555 class ConverterRegressionTest : public ::testing::Test {
66 protected:
67 ConverterRegressionTest() {
68 }
69 virtual ~ConverterRegressionTest() {
70 }
71
72 virtual void SetUp() {
73 user_profile_directory_backup_ = SystemUtil::GetUserProfileDirectory();
74 SystemUtil::SetUserProfileDirectory(FLAGS_test_tmpdir);
75 #ifdef MOZC_USE_PACKED_DICTIONARY
76 // Use a full-size dictionary for regression tests.
77 std::unique_ptr<mozc::packed::PackedDataManager>
78 data_manager(new mozc::packed::PackedDataManager);
79 CHECK(data_manager->Init(string(kPackedSystemDictionary_data,
80 kPackedSystemDictionary_size)));
81 mozc::packed::RegisterPackedDataManager(data_manager.release());
82 #endif // MOZC_USE_PACKED_DICTIONARY
83 }
84
85 virtual void TearDown() {
86 #ifdef MOZC_USE_PACKED_DICTIONARY
87 mozc::packed::RegisterPackedDataManager(nullptr);
88 #endif // MOZC_USE_PACKED_DICTIONARY
89 SystemUtil::SetUserProfileDirectory(user_profile_directory_backup_);
90 }
91
9256 private:
93 string user_profile_directory_backup_;
57 const testing::ScopedTmpUserProfileDirectory scoped_profile_dir_;
9458 };
9559
9660 TEST_F(ConverterRegressionTest, QueryOfDeathTest) {
9191 '../protocol/protocol.gyp:commands_proto',
9292 '../session/session_base.gyp:request_test_util',
9393 '../testing/testing.gyp:gtest_main',
94 ],
95 'conditions': [
96 ['use_packed_dictionary==1 and branding=="Mozc"', {
97 'dependencies': [
98 '../data_manager/packed/packed_data_manager.gyp:gen_packed_data_header_oss#host',
99 '../data_manager/packed/packed_data_manager_base.gyp:packed_data_manager',
100 ],
101 }],
94 '../testing/testing.gyp:mozctest',
10295 ],
10396 },
10497 {
4545 #include "protocol/commands.pb.h"
4646 #include "protocol/config.pb.h"
4747 #include "session/request_test_util.h"
48 #include "testing/base/public/googletest.h"
4948 #include "testing/base/public/gunit.h"
50
51 #ifdef MOZC_USE_PACKED_DICTIONARY
52 #include "data_manager/packed/packed_data_oss.h"
53 #include "data_manager/packed/packed_data_manager.h"
54 #endif // MOZC_USE_PACKED_DICTIONARY
49 #include "testing/base/public/mozctest.h"
5550
5651 using mozc::quality_regression::QualityRegressionUtil;
5752
6661
6762 namespace {
6863
69 class QualityRegressionTest : public testing::Test {
64 class QualityRegressionTest : public ::testing::Test {
7065 protected:
71 virtual void SetUp() {
72 SystemUtil::SetUserProfileDirectory(FLAGS_test_tmpdir);
73
74 #ifdef MOZC_USE_PACKED_DICTIONARY
75 // Registers full-size PackedDataManager.
76 std::unique_ptr<mozc::packed::PackedDataManager> data_manager(
77 new mozc::packed::PackedDataManager());
78 CHECK(data_manager->Init(string(kPackedSystemDictionary_data,
79 kPackedSystemDictionary_size)));
80 mozc::packed::RegisterPackedDataManager(data_manager.release());
81 #endif // MOZC_USE_PACKED_DICTIONARY
82 }
83
84 virtual void TearDown() {
85 #ifdef MOZC_USE_PACKED_DICTIONARY
86 // Unregisters mocked PackedDataManager.
87 mozc::packed::RegisterPackedDataManager(nullptr);
88 #endif // MOZC_USE_PACKED_DICTIONARY
89 }
90
9166 static void RunTestForPlatform(uint32 platform, QualityRegressionUtil *util) {
9267 CHECK(util);
9368 map<string, vector<pair<float, string>>> results, disabled_results;
176151 }
177152 }
178153 }
154
155 private:
156 const testing::ScopedTmpUserProfileDirectory scoped_profile_dir_;
179157 };
180158
181159
134134 'oss_engine_factory',
135135 ],
136136 'conditions': [
137 ['use_packed_dictionary==1', {
138 'dependencies': [
139 'packed_engine_factory'
140 ],
141 'dependencies!': [
142 'oss_engine_factory',
143 ]
144 }],
145137 ],
146138 },
147139 ],
3030 #define MOZC_ENGINE_ENGINE_FACTORY_H_
3131
3232
33 #if defined(MOZC_USE_PACKED_DICTIONARY)
34 #include "engine/packed_engine_factory.h"
35 namespace mozc {
36 typedef PackedEngineFactory EngineFactory;
37 }
38 #else // !MOZC_USE_PACKED_DICTIONARY
3933 #include "engine/oss_engine_factory.h"
4034 namespace mozc {
4135 typedef OssEngineFactory EngineFactory;
4236 }
43 #endif // MOZC_USE_PACKED_DICTIONARY
4437
4538 #endif // MOZC_ENGINE_ENGINE_FACTORY_H_
3232 #include <string>
3333
3434 #include "base/logging.h"
35 #ifdef MOZC_USE_PACKED_DICTIONARY
36 #include "data_manager/packed/packed_data_manager.h"
37 #include "data_manager/packed/packed_data_mock.h"
38 #endif // MOZC_USE_PACKED_DICTIONARY
3935 #include "engine/engine_interface.h"
4036 #include "prediction/predictor_interface.h"
4137 #include "testing/base/public/gunit.h"
4238
4339 namespace mozc {
4440
45 class EngineFactoryTest : public testing::Test {
46 protected:
47 virtual void SetUp() {
48 #ifdef MOZC_USE_PACKED_DICTIONARY
49 // Registers mocked PackedDataManager.
50 std::unique_ptr<packed::PackedDataManager>
51 data_manager(new packed::PackedDataManager());
52 CHECK(data_manager->Init(string(kPackedSystemDictionary_data,
53 kPackedSystemDictionary_size)));
54 packed::RegisterPackedDataManager(data_manager.release());
55 #endif // MOZC_USE_PACKED_DICTIONARY
56 }
57
58 virtual void TearDown() {
59 #ifdef MOZC_USE_PACKED_DICTIONARY
60 // Unregisters mocked PackedDataManager.
61 packed::RegisterPackedDataManager(nullptr);
62 #endif // MOZC_USE_PACKED_DICTIONARY
63 }
64 };
65
66 TEST_F(EngineFactoryTest, MobilePredictorOnAndroid) {
41 TEST(EngineFactoryTest, MobilePredictorOnAndroid) {
6742 std::unique_ptr<EngineInterface> engine(EngineFactory::Create());
6843 PredictorInterface *predictor = engine->GetPredictor();
6944 #ifdef OS_ANDROID
00 MAJOR=2
11 MINOR=17
2 BUILD=2533
2 BUILD=2534
33 REVISION=102
44 # NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
55 # downloaded by NaCl Mozc.