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

Side by Side Diff: chrome/browser/notifications/platform_notification_service_unittest.cc

Issue 1739183003: Make extensions::DictionaryBuilder and extensions::ListValue unmovable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 TEST_F(PlatformNotificationServiceTest, DisplayNameForContextMessage) { 287 TEST_F(PlatformNotificationServiceTest, DisplayNameForContextMessage) {
288 base::string16 display_name = service()->DisplayNameForContextMessage( 288 base::string16 display_name = service()->DisplayNameForContextMessage(
289 profile(), GURL("https://chrome.com/")); 289 profile(), GURL("https://chrome.com/"));
290 290
291 EXPECT_TRUE(display_name.empty()); 291 EXPECT_TRUE(display_name.empty());
292 292
293 // Create a mocked extension. 293 // Create a mocked extension.
294 scoped_refptr<extensions::Extension> extension = 294 scoped_refptr<extensions::Extension> extension =
295 extensions::ExtensionBuilder() 295 extensions::ExtensionBuilder()
296 .SetID("honijodknafkokifofgiaalefdiedpko") 296 .SetID("honijodknafkokifofgiaalefdiedpko")
297 .SetManifest(std::move(extensions::DictionaryBuilder() 297 .SetManifest(extensions::DictionaryBuilder()
298 .Set("name", "NotificationTest") 298 .Set("name", "NotificationTest")
299 .Set("version", "1.0") 299 .Set("version", "1.0")
300 .Set("manifest_version", 2) 300 .Set("manifest_version", 2)
301 .Set("description", "Test Extension"))) 301 .Set("description", "Test Extension")
302 .Build())
302 .Build(); 303 .Build();
303 304
304 extensions::ExtensionRegistry* registry = 305 extensions::ExtensionRegistry* registry =
305 extensions::ExtensionRegistry::Get(profile()); 306 extensions::ExtensionRegistry::Get(profile());
306 EXPECT_TRUE(registry->AddEnabled(extension)); 307 EXPECT_TRUE(registry->AddEnabled(extension));
307 308
308 display_name = service()->DisplayNameForContextMessage( 309 display_name = service()->DisplayNameForContextMessage(
309 profile(), 310 profile(),
310 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html")); 311 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"));
311 EXPECT_EQ("NotificationTest", base::UTF16ToUTF8(display_name)); 312 EXPECT_EQ("NotificationTest", base::UTF16ToUTF8(display_name));
(...skipping 14 matching lines...) Expand all
326 327
327 ExtensionService* extension_service = 328 ExtensionService* extension_service =
328 test_extension_system->CreateExtensionService( 329 test_extension_system->CreateExtensionService(
329 &command_line, base::FilePath() /* install_directory */, 330 &command_line, base::FilePath() /* install_directory */,
330 false /* autoupdate_enabled */); 331 false /* autoupdate_enabled */);
331 332
332 // Create a mocked extension that has the notifications API permission. 333 // Create a mocked extension that has the notifications API permission.
333 scoped_refptr<extensions::Extension> extension = 334 scoped_refptr<extensions::Extension> extension =
334 extensions::ExtensionBuilder() 335 extensions::ExtensionBuilder()
335 .SetManifest( 336 .SetManifest(
336 std::move(extensions::DictionaryBuilder() 337 extensions::DictionaryBuilder()
337 .Set("name", "NotificationTest") 338 .Set("name", "NotificationTest")
338 .Set("version", "1.0") 339 .Set("version", "1.0")
339 .Set("manifest_version", 2) 340 .Set("manifest_version", 2)
340 .Set("description", "Test Extension") 341 .Set("description", "Test Extension")
341 .Set("permissions", 342 .Set(
342 std::move(extensions::ListBuilder().Append( 343 "permissions",
343 "notifications"))))) 344 extensions::ListBuilder().Append("notifications").Build())
345 .Build())
344 .Build(); 346 .Build();
345 347
346 // Install the extension on the faked extension service, and verify that it 348 // Install the extension on the faked extension service, and verify that it
347 // has been added to the extension registry successfully. 349 // has been added to the extension registry successfully.
348 extension_service->AddExtension(extension.get()); 350 extension_service->AddExtension(extension.get());
349 extensions::ExtensionRegistry* registry = 351 extensions::ExtensionRegistry* registry =
350 extensions::ExtensionRegistry::Get(profile()); 352 extensions::ExtensionRegistry::Get(profile());
351 353
352 ASSERT_TRUE(registry->GetExtensionById( 354 ASSERT_TRUE(registry->GetExtensionById(
353 extension->id(), extensions::ExtensionRegistry::ENABLED)); 355 extension->id(), extensions::ExtensionRegistry::ENABLED));
(...skipping 21 matching lines...) Expand all
375 377
376 Notification notification = service()->CreateNotificationFromData( 378 Notification notification = service()->CreateNotificationFromData(
377 profile(), GURL("https://chrome.com/"), notification_data, 379 profile(), GURL("https://chrome.com/"), notification_data,
378 NotificationResources(), new MockNotificationDelegate("hello")); 380 NotificationResources(), new MockNotificationDelegate("hello"));
379 EXPECT_TRUE(notification.context_message().empty()); 381 EXPECT_TRUE(notification.context_message().empty());
380 382
381 // Create a mocked extension. 383 // Create a mocked extension.
382 scoped_refptr<extensions::Extension> extension = 384 scoped_refptr<extensions::Extension> extension =
383 extensions::ExtensionBuilder() 385 extensions::ExtensionBuilder()
384 .SetID("honijodknafkokifofgiaalefdiedpko") 386 .SetID("honijodknafkokifofgiaalefdiedpko")
385 .SetManifest(std::move(extensions::DictionaryBuilder() 387 .SetManifest(extensions::DictionaryBuilder()
386 .Set("name", "NotificationTest") 388 .Set("name", "NotificationTest")
387 .Set("version", "1.0") 389 .Set("version", "1.0")
388 .Set("manifest_version", 2) 390 .Set("manifest_version", 2)
389 .Set("description", "Test Extension"))) 391 .Set("description", "Test Extension")
392 .Build())
390 .Build(); 393 .Build();
391 394
392 extensions::ExtensionRegistry* registry = 395 extensions::ExtensionRegistry* registry =
393 extensions::ExtensionRegistry::Get(profile()); 396 extensions::ExtensionRegistry::Get(profile());
394 EXPECT_TRUE(registry->AddEnabled(extension)); 397 EXPECT_TRUE(registry->AddEnabled(extension));
395 398
396 notification = service()->CreateNotificationFromData( 399 notification = service()->CreateNotificationFromData(
397 profile(), 400 profile(),
398 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"), 401 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"),
399 notification_data, NotificationResources(), 402 notification_data, NotificationResources(),
400 new MockNotificationDelegate("hello")); 403 new MockNotificationDelegate("hello"));
401 EXPECT_EQ("NotificationTest", 404 EXPECT_EQ("NotificationTest",
402 base::UTF16ToUTF8(notification.context_message())); 405 base::UTF16ToUTF8(notification.context_message()));
403 } 406 }
404 407
405 #endif // defined(ENABLE_EXTENSIONS) 408 #endif // defined(ENABLE_EXTENSIONS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698