Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/metrics/histogram.h" | 6 #include "base/metrics/histogram.h" |
| 7 #include "base/metrics/histogram_samples.h" | 7 #include "base/metrics/histogram_samples.h" |
| 8 #include "base/metrics/statistics_recorder.h" | 8 #include "base/metrics/statistics_recorder.h" |
| 9 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" | 9 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" |
| 10 #include "chrome/browser/chromeos/input_method/input_method_engine.h" | 10 #include "chrome/browser/chromeos/input_method/input_method_engine.h" |
| 11 #include "chrome/browser/chromeos/input_method/input_method_engine_interface.h" | 11 #include "chrome/browser/chromeos/input_method/input_method_engine_interface.h" |
| 12 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" | 12 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" |
| 13 #include "chromeos/ime/extension_ime_util.h" | 13 #include "chromeos/ime/extension_ime_util.h" |
| 14 #include "chromeos/ime/mock_component_extension_ime_manager_delegate.h" | 14 #include "chromeos/ime/mock_component_extension_ime_manager_delegate.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "ui/base/ime/chromeos/mock_ime_input_context_handler.h" | 16 #include "ui/base/ime/chromeos/mock_ime_input_context_handler.h" |
| 17 | 17 |
| 18 namespace chromeos { | 18 namespace chromeos { |
| 19 | 19 |
| 20 namespace input_method { | 20 namespace input_method { |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 const char kTestExtensionId[] = "mppnpdlheglhdfmldimlhpnegondlapf"; | 23 const char kTestExtensionId[] = "mppnpdlheglhdfmldimlhpnegondlapf"; |
| 24 const char kTestExtensionId2[] = "dmpipdbjkoajgdeppkffbjhngfckdloi"; | 24 const char kTestExtensionId2[] = "dmpipdbjkoajgdeppkffbjhngfckdloi"; |
| 25 const char kTestImeComponentId[] = "test_engine_id"; | 25 const char kTestImeComponentId[] = "test_engine_id"; |
| 26 | 26 |
| 27 const char* kHistogramNames[] = { | 27 const char* kHistogramNames[] = { |
| 28 "InputMethod.Enable.test_engine_id", "InputMethod.Commit.test_engine_id", | 28 "InputMethod.CommitLength", |
| 29 "InputMethod.CommitCharacter.test_engine_id", | |
| 30 }; | 29 }; |
| 31 | 30 |
| 32 scoped_ptr<base::HistogramSamples> GetHistogramSamples( | 31 scoped_ptr<base::HistogramSamples> GetHistogramSamples( |
| 33 const char* histogram_name) { | 32 const char* histogram_name) { |
| 34 base::HistogramBase* histogram = | 33 base::HistogramBase* histogram = |
| 35 base::StatisticsRecorder::FindHistogram(histogram_name); | 34 base::StatisticsRecorder::FindHistogram(histogram_name); |
| 36 EXPECT_NE(static_cast<base::HistogramBase*>(NULL), histogram); | 35 EXPECT_NE(static_cast<base::HistogramBase*>(NULL), histogram); |
| 37 return histogram->SnapshotSamples().Pass(); | 36 return histogram->SnapshotSamples().Pass(); |
| 38 } | 37 } |
| 39 | 38 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 FocusIn(ui::TEXT_INPUT_TYPE_PASSWORD); | 272 FocusIn(ui::TEXT_INPUT_TYPE_PASSWORD); |
| 274 EXPECT_EQ(ONFOCUS, observer_->GetCallsBitmapAndReset()); | 273 EXPECT_EQ(ONFOCUS, observer_->GetCallsBitmapAndReset()); |
| 275 engine_->Disable(); | 274 engine_->Disable(); |
| 276 EXPECT_EQ(DEACTIVATED, observer_->GetCallsBitmapAndReset()); | 275 EXPECT_EQ(DEACTIVATED, observer_->GetCallsBitmapAndReset()); |
| 277 } | 276 } |
| 278 | 277 |
| 279 TEST_F(InputMethodEngineTest, TestHistograms) { | 278 TEST_F(InputMethodEngineTest, TestHistograms) { |
| 280 CreateEngine(true); | 279 CreateEngine(true); |
| 281 FocusIn(ui::TEXT_INPUT_TYPE_TEXT); | 280 FocusIn(ui::TEXT_INPUT_TYPE_TEXT); |
| 282 engine_->Enable(kTestImeComponentId); | 281 engine_->Enable(kTestImeComponentId); |
| 282 std::vector<InputMethodEngineInterface::SegmentInfo> segments; | |
| 283 engine_->SetComposition( | |
| 284 engine_->GetCotextIdForTesting(), "test", 0, 0, 0, segments, NULL); | |
| 283 std::string error; | 285 std::string error; |
| 284 ExpectNewSample("InputMethod.Enable.test_engine_id", 1, 1, 1); | |
| 285 engine_->CommitText(1, "input", &error); | 286 engine_->CommitText(1, "input", &error); |
| 286 engine_->CommitText(1, "入力", &error); | 287 engine_->CommitText(1, "入力", &error); |
|
Seigo Nonaka
2014/09/12 02:15:37
I prefer "\xE5\x85\xA5\xE5\x8A\x9B" with comment l
Shu Chen
2014/09/12 02:57:18
Done.
| |
| 287 engine_->CommitText(1, "input入力", &error); | 288 engine_->CommitText(1, "input入力", &error); |
| 288 ExpectNewSample("InputMethod.Commit.test_engine_id", 1, 3, 3); | 289 ExpectNewSample("InputMethod.CommitLength", 5, 3, 1); |
| 289 ExpectNewSample("InputMethod.CommitCharacter.test_engine_id", 5, 3, 1); | 290 ExpectNewSample("InputMethod.CommitLength", 2, 3, 1); |
| 290 ExpectNewSample("InputMethod.CommitCharacter.test_engine_id", 2, 3, 1); | 291 ExpectNewSample("InputMethod.CommitLength", 7, 3, 1); |
| 291 ExpectNewSample("InputMethod.CommitCharacter.test_engine_id", 7, 3, 1); | |
| 292 } | 292 } |
| 293 | 293 |
| 294 } // namespace input_method | 294 } // namespace input_method |
| 295 } // namespace chromeos | 295 } // namespace chromeos |
| OLD | NEW |