Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions components/search/src/configuration_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ pub(crate) struct JSONEngineBase {
pub charset: Option<String>,

/// The classification of search engine according to the main search types
/// (e.g. general, shopping, travel, dictionary). Currently, only marking as
/// a general search engine is supported.
/// (e.g. general, ai, and unknown).
#[serde(default)]
pub classification: SearchEngineClassification,

Expand Down
12 changes: 9 additions & 3 deletions components/search/src/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ mod tests {
json!({
"data": [
EngineRecord::full("test1", "Test 1").build(),
EngineRecord::minimal("test2", "Test 2").build(),
EngineRecord::minimal("test2", "Test 2")
.classification("ai")
.build(),
{
"recordType": "defaultEngines",
"globalDefault": "test1",
Expand All @@ -312,8 +314,12 @@ mod tests {
result.unwrap(),
RefinedSearchConfig {
engines: vec!(
ExpectedEngine::full("test1", "Test 1").build(),
ExpectedEngine::minimal("test2", "Test 2").build(),
ExpectedEngine::full("test1", "Test 1")
.classification(SearchEngineClassification::General)
.build(),
ExpectedEngine::minimal("test2", "Test 2")
.classification(SearchEngineClassification::Ai)
.build(),
),
app_default_engine_id: Some("test1".to_string()),
app_private_default_engine_id: Some("test2".to_string())
Expand Down
10 changes: 10 additions & 0 deletions components/search/src/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ impl EngineRecord {
record
}

pub fn classification(mut self, classification: &str) -> Self {
self.classification = classification.to_string();
self
}

pub fn add_variant(mut self, vb: Variant) -> Self {
self.variants.push(vb.build());
self
Expand Down Expand Up @@ -359,6 +364,11 @@ impl ExpectedEngine {
}
}

pub fn classification(mut self, classification: SearchEngineClassification) -> Self {
self.engine.classification = classification;
self
}

pub fn partner_code(mut self, code: &str) -> Self {
self.engine.partner_code = code.to_string();
self
Expand Down
4 changes: 3 additions & 1 deletion components/search/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,18 @@ pub struct SearchEngineUrls {
#[derive(Debug, uniffi::Enum, PartialEq, Deserialize, Clone, Default)]
#[serde(rename_all = "lowercase")]
pub enum SearchEngineClassification {
General = 2,
#[default]
Unknown = 1,
General = 2,
Ai = 3,
}

impl SearchEngineClassification {
pub fn as_str(&self) -> &'static str {
match self {
SearchEngineClassification::Unknown => "unknown",
SearchEngineClassification::General => "general",
SearchEngineClassification::Ai => "ai",
}
}
}
Expand Down