-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[116] CSC: Add VisualSearchSuggestionsServiceBrowserTest
Also disables factory on Android - which was not meant to be enabled to begin with since this feature is built for Chrome desktop. (cherry picked from commit 3869bda) Bug: 1455543 Change-Id: I9165f534422e6a1615015207c6a924ce0d876405 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4616895 Reviewed-by: Michael Crouse <mcrouse@chromium.org> Commit-Queue: Michael Crouse <mcrouse@chromium.org> Auto-Submit: Serena Pascual <srna@google.com> Cr-Original-Commit-Position: refs/heads/main@{#1161286} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4659682 Reviewed-by: Ali Stanfield <stanfield@google.com> Reviewed-by: Stefan Kuhne <skuhne@chromium.org> Commit-Queue: Pierre St Juste <pstjuste@google.com> Cr-Commit-Position: refs/branch-heads/5845@{#266} Cr-Branched-From: 5a5dff6-refs/heads/main@{#1160321}
- Loading branch information
1 parent
dd05f89
commit 5336205
Showing
8 changed files
with
120 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
chrome/browser/companion/visual_search/visual_search_suggestions_service_browsertest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "base/memory/scoped_refptr.h" | ||
#include "base/task/sequenced_task_runner.h" | ||
#include "base/task/thread_pool.h" | ||
#include "base/test/metrics/histogram_tester.h" | ||
#include "base/test/scoped_feature_list.h" | ||
#include "chrome/browser/companion/visual_search/features.h" | ||
#include "chrome/browser/companion/visual_search/visual_search_suggestions_service_factory.h" | ||
#include "chrome/browser/profiles/profile.h" | ||
#include "chrome/browser/ui/browser.h" | ||
#include "chrome/test/base/in_process_browser_test.h" | ||
#include "components/optimization_guide/core/test_model_info_builder.h" | ||
#include "components/optimization_guide/core/test_optimization_guide_model_provider.h" | ||
#include "content/public/test/browser_test.h" | ||
#include "content/public/test/browser_test_utils.h" | ||
#include "net/test/embedded_test_server/embedded_test_server.h" | ||
#include "net/test/embedded_test_server/http_request.h" | ||
#include "net/test/embedded_test_server/http_response.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace { | ||
|
||
class VisualSearchSuggestionsServiceDisabledBrowserTest | ||
: public InProcessBrowserTest { | ||
public: | ||
VisualSearchSuggestionsServiceDisabledBrowserTest() { | ||
scoped_feature_list_.InitAndDisableFeature( | ||
companion::visual_search::features::kVisualSearchSuggestions); | ||
} | ||
|
||
void SetUpOnMainThread() override { | ||
InProcessBrowserTest::SetUpOnMainThread(); | ||
background_task_runner = base::ThreadPool::CreateSequencedTaskRunner( | ||
{base::MayBlock(), base::TaskPriority::BEST_EFFORT}); | ||
test_model_provider_ = std::make_unique< | ||
optimization_guide::TestOptimizationGuideModelProvider>(); | ||
} | ||
|
||
private: | ||
base::test::ScopedFeatureList scoped_feature_list_; | ||
scoped_refptr<base::SequencedTaskRunner> background_task_runner; | ||
std::unique_ptr<optimization_guide::TestOptimizationGuideModelProvider> | ||
test_model_provider_; | ||
}; | ||
|
||
IN_PROC_BROWSER_TEST_F(VisualSearchSuggestionsServiceDisabledBrowserTest, | ||
VisualSearchSuggestionsServiceDisabled) { | ||
EXPECT_FALSE(companion::visual_search::VisualSearchSuggestionsServiceFactory:: | ||
GetForProfile(browser()->profile())); | ||
} | ||
|
||
class VisualSearchSuggestionsServiceBrowserTest | ||
: public VisualSearchSuggestionsServiceDisabledBrowserTest { | ||
public: | ||
VisualSearchSuggestionsServiceBrowserTest() { | ||
scoped_feature_list_.InitWithFeatures( | ||
{companion::visual_search::features::kVisualSearchSuggestions}, {}); | ||
} | ||
|
||
companion::visual_search::VisualSearchSuggestionsService* | ||
visual_search_suggestions_service() { | ||
return companion::visual_search::VisualSearchSuggestionsServiceFactory:: | ||
GetForProfile(browser()->profile()); | ||
} | ||
|
||
~VisualSearchSuggestionsServiceBrowserTest() override = default; | ||
|
||
private: | ||
base::test::ScopedFeatureList scoped_feature_list_; | ||
}; | ||
|
||
IN_PROC_BROWSER_TEST_F(VisualSearchSuggestionsServiceBrowserTest, | ||
VisualSearchSuggestionsServiceEnabled) { | ||
EXPECT_TRUE(visual_search_suggestions_service()); | ||
} | ||
|
||
} // namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters