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

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_handler.h"
20 #include "chrome/common/extensions/url_pattern.h"
19 #include "content/common/json_value_serializer.h" 21 #include "content/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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 EXPECT_FALSE(extension->is_storage_isolated()); 563 EXPECT_FALSE(extension->is_storage_isolated());
562 564
563 CommandLine old_command_line = *CommandLine::ForCurrentProcess(); 565 CommandLine old_command_line = *CommandLine::ForCurrentProcess();
564 CommandLine::ForCurrentProcess()->AppendSwitch( 566 CommandLine::ForCurrentProcess()->AppendSwitch(
565 switches::kEnableExperimentalAppManifests); 567 switches::kEnableExperimentalAppManifests);
566 scoped_refptr<Extension> extension2( 568 scoped_refptr<Extension> extension2(
567 LoadAndExpectSuccess("isolated_app_valid.json")); 569 LoadAndExpectSuccess("isolated_app_valid.json"));
568 EXPECT_TRUE(extension2->is_storage_isolated()); 570 EXPECT_TRUE(extension2->is_storage_isolated());
569 *CommandLine::ForCurrentProcess() = old_command_line; 571 *CommandLine::ForCurrentProcess() = old_command_line;
570 } 572 }
573
574
575 TEST_F(ExtensionManifestTest, FileBrowserHandlers) {
576 LoadAndExpectError("filebrowser_invalid_actions_1.json",
577 errors::kInvalidFileBrowserHandler);
578 LoadAndExpectError("filebrowser_invalid_actions_2.json",
579 errors::kInvalidFileBrowserHandler);
580 LoadAndExpectError("filebrowser_invalid_action_id.json",
581 errors::kInvalidPageActionId);
582 LoadAndExpectError("filebrowser_invalid_action_title.json",
583 errors::kInvalidPageActionDefaultTitle);
584 LoadAndExpectError("filebrowser_invalid_action_id.json",
585 errors::kInvalidPageActionId);
586 LoadAndExpectError("filebrowser_invalid_file_filters_1.json",
587 errors::kInvalidFileFiltersList);
588 LoadAndExpectError("filebrowser_invalid_file_filters_2.json",
589 ExtensionErrorUtils::FormatErrorMessage(
590 errors::kInvalidFileFilterValue, base::IntToString(0)));
591 LoadAndExpectError("filebrowser_invalid_file_filters_url.json",
592 ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidURLPatternError,
593 "http:*.html"));
594
595 scoped_refptr<Extension> extension(
596 LoadAndExpectSuccess("filebrowser_valid.json"));
597 ASSERT_TRUE(extension->file_browser_handlers() != NULL);
598 ASSERT_EQ(extension->file_browser_handlers()->size(), 1U);
599 const FileBrowserHandler* action =
600 extension->file_browser_handlers()->at(0).get();
601 EXPECT_EQ(action->title(), "Default title");
602 EXPECT_EQ(action->icon_path(), "icon.png");
603 const FileBrowserHandler::PatternList& patterns = action->file_url_patterns();
604 ASSERT_EQ(patterns.size(), 1U);
605 ASSERT_TRUE(action->MatchesURL(
606 GURL("filesystem:chrome-extension://foo/local/test.txt")));
607 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_constants.cc ('k') | chrome/common/extensions/extension_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698