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

Side by Side Diff: chrome/common/extensions/extension_manifests_unittest.cc

Issue 6749021: Added new fileBrowserPrivate and fileHandler extension APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 | Annotate | Revision Log
OLDNEW
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/common/chrome_paths.h" 13 #include "chrome/common/chrome_paths.h"
14 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/extensions/extension.h" 15 #include "chrome/common/extensions/extension.h"
16 #include "chrome/common/extensions/extension_constants.h" 16 #include "chrome/common/extensions/extension_constants.h"
17 #include "chrome/common/extensions/extension_error_utils.h" 17 #include "chrome/common/extensions/extension_error_utils.h"
18 #include "chrome/common/extensions/extension_sidebar_defaults.h" 18 #include "chrome/common/extensions/extension_sidebar_defaults.h"
19 #include "chrome/common/extensions/file_browser_action.h"
20 #include "chrome/common/extensions/url_pattern.h"
19 #include "chrome/common/json_value_serializer.h" 21 #include "chrome/common/json_value_serializer.h"
20 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
21 23
22 namespace errors = extension_manifest_errors; 24 namespace errors = extension_manifest_errors;
23 namespace keys = extension_manifest_keys; 25 namespace keys = extension_manifest_keys;
24 26
25 class ExtensionManifestTest : public testing::Test { 27 class ExtensionManifestTest : public testing::Test {
26 public: 28 public:
27 ExtensionManifestTest() : enable_apps_(true) {} 29 ExtensionManifestTest() : enable_apps_(true) {}
28 30
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 EXPECT_FALSE(extension->is_storage_isolated()); 561 EXPECT_FALSE(extension->is_storage_isolated());
560 562
561 CommandLine old_command_line = *CommandLine::ForCurrentProcess(); 563 CommandLine old_command_line = *CommandLine::ForCurrentProcess();
562 CommandLine::ForCurrentProcess()->AppendSwitch( 564 CommandLine::ForCurrentProcess()->AppendSwitch(
563 switches::kEnableExperimentalAppManifests); 565 switches::kEnableExperimentalAppManifests);
564 scoped_refptr<Extension> extension2( 566 scoped_refptr<Extension> extension2(
565 LoadAndExpectSuccess("isolated_app_valid.json")); 567 LoadAndExpectSuccess("isolated_app_valid.json"));
566 EXPECT_TRUE(extension2->is_storage_isolated()); 568 EXPECT_TRUE(extension2->is_storage_isolated());
567 *CommandLine::ForCurrentProcess() = old_command_line; 569 *CommandLine::ForCurrentProcess() = old_command_line;
568 } 570 }
571
572
573 TEST_F(ExtensionManifestTest, FileBrowserActions) {
574 LoadAndExpectError("filebrowser_invalid_actions_1.json",
575 errors::kInvalidFileBrowserAction);
576 LoadAndExpectError("filebrowser_invalid_actions_2.json",
577 errors::kInvalidFileBrowserAction);
578 LoadAndExpectError("filebrowser_invalid_action_id.json",
579 errors::kInvalidPageActionId);
580 LoadAndExpectError("filebrowser_invalid_action_title.json",
581 errors::kInvalidPageActionDefaultTitle);
582 LoadAndExpectError("filebrowser_invalid_action_id.json",
583 errors::kInvalidPageActionId);
584 LoadAndExpectError("filebrowser_invalid_file_filters_1.json",
585 errors::kInvalidFileFiltersList);
586 LoadAndExpectError("filebrowser_invalid_file_filters_2.json",
587 ExtensionErrorUtils::FormatErrorMessage(
588 errors::kInvalidFileFilterValue, base::IntToString(0)));
589 LoadAndExpectError("filebrowser_invalid_file_filters_url.json",
590 ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidURLPatternError,
591 "http:*.html"));
592
593 scoped_refptr<Extension> extension(
594 LoadAndExpectSuccess("filebrowser_valid.json"));
595 ASSERT_TRUE(extension->file_browser_actions() != NULL);
596 ASSERT_EQ(extension->file_browser_actions()->size(), 1U);
597 const FileBrowserAction* action =
598 extension->file_browser_actions()->at(0).get();
599 EXPECT_EQ(action->default_title(), "Default title");
600 EXPECT_EQ(action->default_icon_path(), "icon.png");
601 const FileBrowserAction::PatternList& patterns = action->patterns();
602 ASSERT_EQ(patterns.size(), 1U);
603 ASSERT_TRUE(action->ContainsURL(
604 GURL("filesystem:chrome-extension://foo/local/test.txt")));
605 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698