OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
6 | 6 |
7 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 | 373 |
374 scoped_refptr<Extension> extension( | 374 scoped_refptr<Extension> extension( |
375 LoadAndExpectSuccess("web_urls_default.json")); | 375 LoadAndExpectSuccess("web_urls_default.json")); |
376 ASSERT_EQ(1u, extension->web_extent().patterns().size()); | 376 ASSERT_EQ(1u, extension->web_extent().patterns().size()); |
377 EXPECT_EQ("*://www.google.com/*", | 377 EXPECT_EQ("*://www.google.com/*", |
378 extension->web_extent().patterns().begin()->GetAsString()); | 378 extension->web_extent().patterns().begin()->GetAsString()); |
379 } | 379 } |
380 | 380 |
381 TEST_F(ExtensionManifestTest, AppLaunchContainer) { | 381 TEST_F(ExtensionManifestTest, AppLaunchContainer) { |
382 scoped_refptr<Extension> extension; | 382 scoped_refptr<Extension> extension; |
383 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePlatformApps); | |
384 | 383 |
385 extension = LoadAndExpectSuccess("launch_tab.json"); | 384 extension = LoadAndExpectSuccess("launch_tab.json"); |
386 EXPECT_EQ(extension_misc::LAUNCH_TAB, extension->launch_container()); | 385 EXPECT_EQ(extension_misc::LAUNCH_TAB, extension->launch_container()); |
387 | 386 |
388 extension = LoadAndExpectSuccess("launch_panel.json"); | 387 extension = LoadAndExpectSuccess("launch_panel.json"); |
389 EXPECT_EQ(extension_misc::LAUNCH_PANEL, extension->launch_container()); | 388 EXPECT_EQ(extension_misc::LAUNCH_PANEL, extension->launch_container()); |
390 | 389 |
391 extension = LoadAndExpectSuccess("launch_default.json"); | 390 extension = LoadAndExpectSuccess("launch_default.json"); |
392 EXPECT_EQ(extension_misc::LAUNCH_TAB, extension->launch_container()); | 391 EXPECT_EQ(extension_misc::LAUNCH_TAB, extension->launch_container()); |
393 | 392 |
394 extension = LoadAndExpectSuccess("launch_width.json"); | 393 extension = LoadAndExpectSuccess("launch_width.json"); |
395 EXPECT_EQ(640, extension->launch_width()); | 394 EXPECT_EQ(640, extension->launch_width()); |
396 | 395 |
397 extension = LoadAndExpectSuccess("launch_height.json"); | 396 extension = LoadAndExpectSuccess("launch_height.json"); |
398 EXPECT_EQ(480, extension->launch_height()); | 397 EXPECT_EQ(480, extension->launch_height()); |
399 | 398 |
400 LoadAndExpectError("launch_window.json", | 399 LoadAndExpectError("launch_window.json", |
401 errors::kInvalidLaunchContainer); | 400 errors::kInvalidLaunchContainer); |
402 LoadAndExpectError("launch_container_invalid_type.json", | 401 LoadAndExpectError("launch_container_invalid_type.json", |
403 errors::kInvalidLaunchContainer); | 402 errors::kInvalidLaunchContainer); |
404 LoadAndExpectError("launch_container_invalid_type_for_platform.json", | |
405 errors::kInvalidLaunchContainerForPlatform); | |
406 LoadAndExpectError("launch_container_invalid_value.json", | 403 LoadAndExpectError("launch_container_invalid_value.json", |
407 errors::kInvalidLaunchContainer); | 404 errors::kInvalidLaunchContainer); |
408 LoadAndExpectError("launch_container_without_launch_url.json", | 405 LoadAndExpectError("launch_container_without_launch_url.json", |
409 errors::kLaunchURLRequired); | 406 errors::kLaunchURLRequired); |
410 LoadAndExpectError("launch_width_invalid.json", | 407 LoadAndExpectError("launch_width_invalid.json", |
411 errors::kInvalidLaunchWidthContainer); | 408 errors::kInvalidLaunchWidthContainer); |
412 LoadAndExpectError("launch_width_negative.json", | 409 LoadAndExpectError("launch_width_negative.json", |
413 errors::kInvalidLaunchWidth); | 410 errors::kInvalidLaunchWidth); |
414 LoadAndExpectError("launch_height_invalid.json", | 411 LoadAndExpectError("launch_height_invalid.json", |
415 errors::kInvalidLaunchHeightContainer); | 412 errors::kInvalidLaunchHeightContainer); |
416 LoadAndExpectError("launch_height_negative.json", | 413 LoadAndExpectError("launch_height_negative.json", |
417 errors::kInvalidLaunchHeight); | 414 errors::kInvalidLaunchHeight); |
418 } | 415 } |
419 | 416 |
| 417 TEST_F(ExtensionManifestTest, PlatformAppLaunchContainer) { |
| 418 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePlatformApps); |
| 419 |
| 420 LoadAndExpectError("launch_container_invalid_type_for_platform.json", |
| 421 errors::kInvalidLaunchContainerForPlatform); |
| 422 } |
| 423 |
420 TEST_F(ExtensionManifestTest, AppLaunchURL) { | 424 TEST_F(ExtensionManifestTest, AppLaunchURL) { |
421 LoadAndExpectError("launch_path_and_url.json", | 425 LoadAndExpectError("launch_path_and_url.json", |
422 errors::kLaunchPathAndURLAreExclusive); | 426 errors::kLaunchPathAndURLAreExclusive); |
423 LoadAndExpectError("launch_path_and_extent.json", | 427 LoadAndExpectError("launch_path_and_extent.json", |
424 errors::kLaunchPathAndExtentAreExclusive); | 428 errors::kLaunchPathAndExtentAreExclusive); |
425 LoadAndExpectError("launch_path_invalid_type.json", | 429 LoadAndExpectError("launch_path_invalid_type.json", |
426 errors::kInvalidLaunchLocalPath); | 430 errors::kInvalidLaunchLocalPath); |
427 LoadAndExpectError("launch_path_invalid_value.json", | 431 LoadAndExpectError("launch_path_invalid_value.json", |
428 errors::kInvalidLaunchLocalPath); | 432 errors::kInvalidLaunchLocalPath); |
429 LoadAndExpectError("launch_url_invalid_type_1.json", | 433 LoadAndExpectError("launch_url_invalid_type_1.json", |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 // This guy is identical to the previous but doesn't ask for any | 992 // This guy is identical to the previous but doesn't ask for any |
989 // platform-app-only permissions. We should be able to load him and ask | 993 // platform-app-only permissions. We should be able to load him and ask |
990 // questions about his permissions. | 994 // questions about his permissions. |
991 scoped_refptr<Extension> extension( | 995 scoped_refptr<Extension> extension( |
992 LoadAndExpectSuccess("not_platform_app.json")); | 996 LoadAndExpectSuccess("not_platform_app.json")); |
993 ExtensionAPIPermissionSet apis = extension->GetActivePermissions()->apis(); | 997 ExtensionAPIPermissionSet apis = extension->GetActivePermissions()->apis(); |
994 for (ExtensionAPIPermissionSet::const_iterator i = apis.begin(); | 998 for (ExtensionAPIPermissionSet::const_iterator i = apis.begin(); |
995 i != apis.end(); ++i) | 999 i != apis.end(); ++i) |
996 EXPECT_NE(platform_app, info->GetByID(*i)->type_restrictions()); | 1000 EXPECT_NE(platform_app, info->GetByID(*i)->type_restrictions()); |
997 } | 1001 } |
OLD | NEW |