Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: components/omnibox/browser/physical_web_provider_unittest.cc

Issue 2231983002: Expose Physical Web data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build errors Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/physical_web/data_source/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/omnibox/browser/physical_web_provider.h" 5 #include "components/omnibox/browser/physical_web_provider.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "components/metrics/proto/omnibox_event.pb.h" 14 #include "components/metrics/proto/omnibox_event.pb.h"
15 #include "components/omnibox/browser/mock_autocomplete_provider_client.h" 15 #include "components/omnibox/browser/mock_autocomplete_provider_client.h"
16 #include "components/omnibox/browser/test_scheme_classifier.h" 16 #include "components/omnibox/browser/test_scheme_classifier.h"
17 #include "components/physical_web/data_source/physical_web_data_source.h" 17 #include "components/physical_web/data_source/physical_web_data_source.h"
18 #include "components/physical_web/data_source/physical_web_listener.h"
18 #include "grit/components_strings.h" 19 #include "grit/components_strings.h"
19 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
22 #include "url/gurl.h" 23 #include "url/gurl.h"
23 24
24 namespace { 25 namespace {
25 26
26 // A mock implementation of the Physical Web data source that allows setting 27 // A mock implementation of the Physical Web data source that allows setting
27 // metadata for nearby URLs directly. 28 // metadata for nearby URLs directly.
28 class MockPhysicalWebDataSource : public PhysicalWebDataSource { 29 class MockPhysicalWebDataSource : public PhysicalWebDataSource {
29 public: 30 public:
30 MockPhysicalWebDataSource() : metadata_(new base::ListValue()) {} 31 MockPhysicalWebDataSource() : metadata_(new base::ListValue()) {}
31 ~MockPhysicalWebDataSource() override {} 32 ~MockPhysicalWebDataSource() override {}
32 33
33 void StartDiscovery(bool network_request_enabled) override {} 34 void StartDiscovery(bool network_request_enabled) override {}
34 void StopDiscovery() override {} 35 void StopDiscovery() override {}
35 36
36 std::unique_ptr<base::ListValue> GetMetadata() override { 37 std::unique_ptr<base::ListValue> GetMetadata() override {
37 return metadata_->CreateDeepCopy(); 38 return metadata_->CreateDeepCopy();
38 } 39 }
39 40
40 bool HasUnresolvedDiscoveries() override { 41 bool HasUnresolvedDiscoveries() override {
41 return false; 42 return false;
42 } 43 }
43 44
45 void RegisterListener(PhysicalWebListener* physical_web_listener) override {}
46
47 void UnregisterListener(
48 PhysicalWebListener* physical_web_listener) override {}
49
44 // for testing 50 // for testing
45 void SetMetadata(std::unique_ptr<base::ListValue> metadata) { 51 void SetMetadata(std::unique_ptr<base::ListValue> metadata) {
46 metadata_ = std::move(metadata); 52 metadata_ = std::move(metadata);
47 } 53 }
48 54
49 private: 55 private:
50 std::unique_ptr<base::ListValue> metadata_; 56 std::unique_ptr<base::ListValue> metadata_;
51 }; 57 };
52 58
53 // An autocomplete provider client that embeds the mock Physical Web data 59 // An autocomplete provider client that embeds the mock Physical Web data
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 const AutocompleteInput input(base::ASCIIToUTF16(text), text.length(), 229 const AutocompleteInput input(base::ASCIIToUTF16(text), text.length(),
224 std::string(), GURL(), 230 std::string(), GURL(),
225 metrics::OmniboxEventProto::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS, 231 metrics::OmniboxEventProto::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS,
226 true, false, true, true, false, TestSchemeClassifier()); 232 true, false, true, true, false, TestSchemeClassifier());
227 provider_->Start(input, false); 233 provider_->Start(input, false);
228 234
229 EXPECT_TRUE(provider_->matches().empty()); 235 EXPECT_TRUE(provider_->matches().empty());
230 } 236 }
231 237
232 } 238 }
OLDNEW
« no previous file with comments | « no previous file | components/physical_web/data_source/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698