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

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

Issue 1463333003: Increase the maximum MDNS device limit from 64 to 2048. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 | chrome/common/extensions/api/mdns.idl » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <vector> 5 #include <vector>
6 6
7 #include "base/memory/linked_ptr.h" 7 #include "base/memory/linked_ptr.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/extensions/api/mdns/mdns_api.h" 9 #include "chrome/browser/extensions/api/mdns/mdns_api.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 // Listener #4 added with kService1. 340 // Listener #4 added with kService1.
341 AddEventListener(kExtId, kService1, &listeners); 341 AddEventListener(kExtId, kService1, &listeners);
342 EXPECT_CALL(*dns_sd_registry(), RegisterDnsSdListener(kService1)); 342 EXPECT_CALL(*dns_sd_registry(), RegisterDnsSdListener(kService1));
343 mdns_api_->OnListenerAdded(listener_info); 343 mdns_api_->OnListenerAdded(listener_info);
344 } 344 }
345 345
346 TEST_F(MDnsAPIMaxServicesTest, OnServiceListDoesNotExceedLimit) { 346 TEST_F(MDnsAPIMaxServicesTest, OnServiceListDoesNotExceedLimit) {
347 EventRouterFactory::GetInstance()->SetTestingFactory( 347 EventRouterFactory::GetInstance()->SetTestingFactory(
348 browser_context(), &MockEventRouterFactoryFunction); 348 browser_context(), &MockEventRouterFactoryFunction);
349 349
350 // This check should change when the [value=64] changes in the IDL file. 350 // This check should change when the [value=2048] changes in the IDL file.
351 EXPECT_EQ(64, api::mdns::MAX_SERVICE_INSTANCES_PER_EVENT); 351 EXPECT_EQ(2048, api::mdns::MAX_SERVICE_INSTANCES_PER_EVENT);
352 352
353 // Dispatch an mDNS event with more service instances than the max, and ensure 353 // Dispatch an mDNS event with more service instances than the max, and ensure
354 // that the list is truncated by inspecting the argument to MockEventRouter's 354 // that the list is truncated by inspecting the argument to MockEventRouter's
355 // BroadcastEvent method. 355 // BroadcastEvent method.
356 DnsSdRegistry::DnsSdServiceList services; 356 DnsSdRegistry::DnsSdServiceList services;
357 for (int i = 0; i < api::mdns::MAX_SERVICE_INSTANCES_PER_EVENT + 10; ++i) { 357 for (int i = 0; i < api::mdns::MAX_SERVICE_INSTANCES_PER_EVENT + 10; ++i) {
358 services.push_back(DnsSdService()); 358 services.push_back(DnsSdService());
359 } 359 }
360 EXPECT_CALL(*event_router(), BroadcastEventPtr(testing::Pointee( 360 EXPECT_CALL(
361 EventServiceListSize(size_t(64))))).Times(1); 361 *event_router(),
362 BroadcastEventPtr(testing::Pointee(EventServiceListSize(
363 static_cast<size_t>(api::mdns::MAX_SERVICE_INSTANCES_PER_EVENT)))))
364 .Times(1);
362 dns_sd_registry()->DispatchMDnsEvent("_testing._tcp.local", services); 365 dns_sd_registry()->DispatchMDnsEvent("_testing._tcp.local", services);
363 } 366 }
364 367
365 TEST_F(MDnsAPITest, ExtensionRespectsWhitelist) { 368 TEST_F(MDnsAPITest, ExtensionRespectsWhitelist) {
366 scoped_refptr<extensions::Extension> extension = 369 scoped_refptr<extensions::Extension> extension =
367 CreateExtension("Dinosaur networker", false, kExtId); 370 CreateExtension("Dinosaur networker", false, kExtId);
368 ExtensionRegistry::Get(browser_context())->AddEnabled(extension); 371 ExtensionRegistry::Get(browser_context())->AddEnabled(extension);
369 ASSERT_EQ(Manifest::TYPE_EXTENSION, extension.get()->GetType()); 372 ASSERT_EQ(Manifest::TYPE_EXTENSION, extension.get()->GetType());
370 373
371 // There is a whitelist of mdns service types extensions may access, which 374 // There is a whitelist of mdns service types extensions may access, which
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 render_process_host(), kExtId, filter, false); 432 render_process_host(), kExtId, filter, false);
430 433
431 EXPECT_CALL(*dns_sd_registry(), UnregisterDnsSdListener("_trex._tcp.local")); 434 EXPECT_CALL(*dns_sd_registry(), UnregisterDnsSdListener("_trex._tcp.local"));
432 EventRouter::Get(browser_context()) 435 EventRouter::Get(browser_context())
433 ->RemoveFilteredEventListener(api::mdns::OnServiceList::kEventName, 436 ->RemoveFilteredEventListener(api::mdns::OnServiceList::kEventName,
434 render_process_host(), kExtId, filter, 437 render_process_host(), kExtId, filter,
435 false); 438 false);
436 } 439 }
437 440
438 } // namespace extensions 441 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/api/mdns.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698