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

Side by Side Diff: chrome/browser/extensions/api/mdns/dns_sd_registry_unittest.cc

Issue 624153002: replace OVERRIDE and FINAL with override and final in chrome/browser/extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/extensions/api/mdns/dns_sd_registry.h" 5 #include "chrome/browser/extensions/api/mdns/dns_sd_registry.h"
6 #include "chrome/browser/extensions/api/mdns/dns_sd_delegate.h" 6 #include "chrome/browser/extensions/api/mdns/dns_sd_delegate.h"
7 #include "chrome/browser/extensions/api/mdns/dns_sd_device_lister.h" 7 #include "chrome/browser/extensions/api/mdns/dns_sd_device_lister.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace extensions { 11 namespace extensions {
12 12
13 class MockDnsSdDeviceLister : public DnsSdDeviceLister { 13 class MockDnsSdDeviceLister : public DnsSdDeviceLister {
14 public: 14 public:
15 MockDnsSdDeviceLister() : DnsSdDeviceLister(NULL, NULL, "") {} 15 MockDnsSdDeviceLister() : DnsSdDeviceLister(NULL, NULL, "") {}
16 virtual ~MockDnsSdDeviceLister() {} 16 virtual ~MockDnsSdDeviceLister() {}
17 17
18 virtual void Discover(bool force_update) OVERRIDE {} 18 virtual void Discover(bool force_update) override {}
19 }; 19 };
20 20
21 class TestDnsSdRegistry : public DnsSdRegistry { 21 class TestDnsSdRegistry : public DnsSdRegistry {
22 public: 22 public:
23 TestDnsSdRegistry() : DnsSdRegistry(NULL), delegate_(NULL) {} 23 TestDnsSdRegistry() : DnsSdRegistry(NULL), delegate_(NULL) {}
24 virtual ~TestDnsSdRegistry() {} 24 virtual ~TestDnsSdRegistry() {}
25 25
26 MockDnsSdDeviceLister* GetListerForService(const std::string& service_type) { 26 MockDnsSdDeviceLister* GetListerForService(const std::string& service_type) {
27 return listers_[service_type]; 27 return listers_[service_type];
28 } 28 }
29 29
30 int GetServiceListenerCount(const std::string& service_type) { 30 int GetServiceListenerCount(const std::string& service_type) {
31 if (service_data_map_.find(service_type) == service_data_map_.end()) 31 if (service_data_map_.find(service_type) == service_data_map_.end())
32 return 0; 32 return 0;
33 33
34 return service_data_map_[service_type].get()->GetListenerCount(); 34 return service_data_map_[service_type].get()->GetListenerCount();
35 } 35 }
36 36
37 DnsSdDelegate* GetDelegate() { 37 DnsSdDelegate* GetDelegate() {
38 return delegate_; 38 return delegate_;
39 } 39 }
40 40
41 protected: 41 protected:
42 virtual DnsSdDeviceLister* CreateDnsSdDeviceLister( 42 virtual DnsSdDeviceLister* CreateDnsSdDeviceLister(
43 DnsSdDelegate* delegate, 43 DnsSdDelegate* delegate,
44 const std::string& service_type, 44 const std::string& service_type,
45 local_discovery::ServiceDiscoverySharedClient* discovery_client) 45 local_discovery::ServiceDiscoverySharedClient* discovery_client)
46 OVERRIDE { 46 override {
47 delegate_ = delegate; 47 delegate_ = delegate;
48 MockDnsSdDeviceLister* lister = new MockDnsSdDeviceLister(); 48 MockDnsSdDeviceLister* lister = new MockDnsSdDeviceLister();
49 listers_[service_type] = lister; 49 listers_[service_type] = lister;
50 return lister; 50 return lister;
51 }; 51 };
52 52
53 private: 53 private:
54 std::map<std::string, MockDnsSdDeviceLister*> listers_; 54 std::map<std::string, MockDnsSdDeviceLister*> listers_;
55 // The last delegate used or NULL. 55 // The last delegate used or NULL.
56 DnsSdDelegate* delegate_; 56 DnsSdDelegate* delegate_;
57 }; 57 };
58 58
59 class MockDnsSdObserver : public DnsSdRegistry::DnsSdObserver { 59 class MockDnsSdObserver : public DnsSdRegistry::DnsSdObserver {
60 public: 60 public:
61 MOCK_METHOD2(OnDnsSdEvent, void(const std::string&, 61 MOCK_METHOD2(OnDnsSdEvent, void(const std::string&,
62 const DnsSdRegistry::DnsSdServiceList&)); 62 const DnsSdRegistry::DnsSdServiceList&));
63 }; 63 };
64 64
65 class DnsSdRegistryTest : public testing::Test { 65 class DnsSdRegistryTest : public testing::Test {
66 public: 66 public:
67 DnsSdRegistryTest() {} 67 DnsSdRegistryTest() {}
68 virtual ~DnsSdRegistryTest() {} 68 virtual ~DnsSdRegistryTest() {}
69 69
70 virtual void SetUp() OVERRIDE { 70 virtual void SetUp() override {
71 registry_.reset(new TestDnsSdRegistry()); 71 registry_.reset(new TestDnsSdRegistry());
72 registry_->AddObserver(&observer_); 72 registry_->AddObserver(&observer_);
73 } 73 }
74 74
75 protected: 75 protected:
76 scoped_ptr<TestDnsSdRegistry> registry_; 76 scoped_ptr<TestDnsSdRegistry> registry_;
77 MockDnsSdObserver observer_; 77 MockDnsSdObserver observer_;
78 }; 78 };
79 79
80 // Tests registering 2 listeners and removing one. The device lister should 80 // Tests registering 2 listeners and removing one. The device lister should
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 service.ip_address = "192.168.0.100"; 228 service.ip_address = "192.168.0.100";
229 registry_->GetDelegate()->ServiceChanged(service_type, true, service); 229 registry_->GetDelegate()->ServiceChanged(service_type, true, service);
230 // Update with changed ip address. 230 // Update with changed ip address.
231 service.ip_address = "192.168.0.101"; 231 service.ip_address = "192.168.0.101";
232 registry_->GetDelegate()->ServiceChanged(service_type, false, service); 232 registry_->GetDelegate()->ServiceChanged(service_type, false, service);
233 // Update with no changes to the service. 233 // Update with no changes to the service.
234 registry_->GetDelegate()->ServiceChanged(service_type, false, service); 234 registry_->GetDelegate()->ServiceChanged(service_type, false, service);
235 } 235 }
236 236
237 } // namespace extensions 237 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/mdns/dns_sd_registry.h ('k') | chrome/browser/extensions/api/mdns/mdns_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698