// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/omnibox/browser/on_device_head_model.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/path_service.h" #include "base/strings/utf_string_conversions.h" #include "base/test/scoped_feature_list.h" #include "build/build_config.h" #include "components/omnibox/browser/omnibox_field_trial.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" ElementsAre; Pair; namespace { // The test head model used for unittests contains 14 queries and their scores // shown below; the test model uses 3-bytes address and 2-bytes score so the // highest score is 32767: // ---------------------- // Query Score // ---------------------- // g 32767 // gmail 32766 // google maps 32765 // google 32764 // get out 32763 // googler 32762 // gamestop 32761 // maps 32761 // mail 32760 // map 32759 // 谷歌 32759 // ガツガツしてる人 32759 // 비데 두꺼비 32759 // переводчик 32759 // ---------------------- // The tree structure for queries above is similar as this: // [ g | ma | 谷歌 | ガツガツしてる人| 비데 두꺼비 | переводчик ] // | | // | [ p | il ] // | | // | [ # | s ] // | // [ # | oogle | mail | et out | amestop ] // | // [ # | _maps | er ] base::FilePath GetTestModelPath() { … } } // namespace class OnDeviceHeadModelTest : public testing::Test { … }; TEST_F(OnDeviceHeadModelTest, GetSuggestions) { … } TEST_F(OnDeviceHeadModelTest, NoMatch) { … } TEST_F(OnDeviceHeadModelTest, MatchTheEndOfSuggestion) { … } TEST_F(OnDeviceHeadModelTest, MatchAtTheMiddleOfSuggestion) { … } TEST_F(OnDeviceHeadModelTest, EmptyInput) { … } TEST_F(OnDeviceHeadModelTest, SetMaxSuggestionsToReturn) { … } TEST_F(OnDeviceHeadModelTest, NonEnglishLanguage) { … } // Test for https://crbug.com/1506547. Similar to // OnDeviceHeadModelTest.GetSuggestions but search results are collected from // deeper and wider subtree. Closer to what is done in real model. TEST(OnDeviceHeadDeepModelTest, SearchSuggestions) { … }