OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/auto_reset.h" | 5 #include "base/auto_reset.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 const MediaFolderFinderResultsCallback& callback) | 71 const MediaFolderFinderResultsCallback& callback) |
72 : MediaFolderFinder(callback) { | 72 : MediaFolderFinder(callback) { |
73 } | 73 } |
74 virtual ~DoNothingMediaFolderFinder() {} | 74 virtual ~DoNothingMediaFolderFinder() {} |
75 | 75 |
76 static MediaFolderFinder* CreateDoNothingMediaFolderFinder( | 76 static MediaFolderFinder* CreateDoNothingMediaFolderFinder( |
77 const MediaFolderFinderResultsCallback& callback) { | 77 const MediaFolderFinderResultsCallback& callback) { |
78 return new DoNothingMediaFolderFinder(callback); | 78 return new DoNothingMediaFolderFinder(callback); |
79 } | 79 } |
80 | 80 |
81 virtual void StartScan() OVERRIDE {} | 81 virtual void StartScan() override {} |
82 | 82 |
83 private: | 83 private: |
84 }; | 84 }; |
85 | 85 |
86 } // namespace | 86 } // namespace |
87 | 87 |
88 class TestMediaGalleriesAddScanResultsFunction | 88 class TestMediaGalleriesAddScanResultsFunction |
89 : public extensions::MediaGalleriesAddScanResultsFunction { | 89 : public extensions::MediaGalleriesAddScanResultsFunction { |
90 public: | 90 public: |
91 static ExtensionFunction* Factory() { | 91 static ExtensionFunction* Factory() { |
92 return new TestMediaGalleriesAddScanResultsFunction; | 92 return new TestMediaGalleriesAddScanResultsFunction; |
93 } | 93 } |
94 | 94 |
95 protected: | 95 protected: |
96 virtual ~TestMediaGalleriesAddScanResultsFunction() {} | 96 virtual ~TestMediaGalleriesAddScanResultsFunction() {} |
97 | 97 |
98 // Accepts the dialog as soon as it is created. | 98 // Accepts the dialog as soon as it is created. |
99 virtual MediaGalleriesScanResultController* MakeDialog( | 99 virtual MediaGalleriesScanResultController* MakeDialog( |
100 content::WebContents* web_contents, | 100 content::WebContents* web_contents, |
101 const extensions::Extension& extension, | 101 const extensions::Extension& extension, |
102 const base::Closure& on_finish) OVERRIDE { | 102 const base::Closure& on_finish) override { |
103 MediaGalleriesScanResultController* controller = | 103 MediaGalleriesScanResultController* controller = |
104 extensions::MediaGalleriesAddScanResultsFunction::MakeDialog( | 104 extensions::MediaGalleriesAddScanResultsFunction::MakeDialog( |
105 web_contents, extension, on_finish); | 105 web_contents, extension, on_finish); |
106 controller->dialog_->AcceptDialogForTesting(); | 106 controller->dialog_->AcceptDialogForTesting(); |
107 // The dialog is closing or closed so don't return it. | 107 // The dialog is closing or closed so don't return it. |
108 return NULL; | 108 return NULL; |
109 } | 109 } |
110 }; | 110 }; |
111 | 111 |
112 class MediaGalleriesPlatformAppBrowserTest : public PlatformAppBrowserTest { | 112 class MediaGalleriesPlatformAppBrowserTest : public PlatformAppBrowserTest { |
113 protected: | 113 protected: |
114 MediaGalleriesPlatformAppBrowserTest() : test_jpg_size_(0) {} | 114 MediaGalleriesPlatformAppBrowserTest() : test_jpg_size_(0) {} |
115 virtual ~MediaGalleriesPlatformAppBrowserTest() {} | 115 virtual ~MediaGalleriesPlatformAppBrowserTest() {} |
116 | 116 |
117 virtual void SetUpOnMainThread() OVERRIDE { | 117 virtual void SetUpOnMainThread() override { |
118 PlatformAppBrowserTest::SetUpOnMainThread(); | 118 PlatformAppBrowserTest::SetUpOnMainThread(); |
119 ensure_media_directories_exists_.reset(new EnsureMediaDirectoriesExists); | 119 ensure_media_directories_exists_.reset(new EnsureMediaDirectoriesExists); |
120 | 120 |
121 int64 file_size; | 121 int64 file_size; |
122 ASSERT_TRUE(base::GetFileSize(GetCommonDataDir().AppendASCII("test.jpg"), | 122 ASSERT_TRUE(base::GetFileSize(GetCommonDataDir().AppendASCII("test.jpg"), |
123 &file_size)); | 123 &file_size)); |
124 test_jpg_size_ = base::checked_cast<int>(file_size); | 124 test_jpg_size_ = base::checked_cast<int>(file_size); |
125 } | 125 } |
126 | 126 |
127 virtual void TearDownOnMainThread() OVERRIDE { | 127 virtual void TearDownOnMainThread() override { |
128 ensure_media_directories_exists_.reset(); | 128 ensure_media_directories_exists_.reset(); |
129 PlatformAppBrowserTest::TearDownOnMainThread(); | 129 PlatformAppBrowserTest::TearDownOnMainThread(); |
130 } | 130 } |
131 | 131 |
132 bool RunMediaGalleriesTest(const std::string& extension_name) { | 132 bool RunMediaGalleriesTest(const std::string& extension_name) { |
133 base::ListValue empty_list_value; | 133 base::ListValue empty_list_value; |
134 return RunMediaGalleriesTestWithArg(extension_name, empty_list_value); | 134 return RunMediaGalleriesTestWithArg(extension_name, empty_list_value); |
135 } | 135 } |
136 | 136 |
137 bool RunMediaGalleriesTestWithArg(const std::string& extension_name, | 137 bool RunMediaGalleriesTestWithArg(const std::string& extension_name, |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 std::string device_id_; | 431 std::string device_id_; |
432 base::ScopedTempDir fake_gallery_temp_dir_; | 432 base::ScopedTempDir fake_gallery_temp_dir_; |
433 int test_jpg_size_; | 433 int test_jpg_size_; |
434 scoped_ptr<EnsureMediaDirectoriesExists> ensure_media_directories_exists_; | 434 scoped_ptr<EnsureMediaDirectoriesExists> ensure_media_directories_exists_; |
435 }; | 435 }; |
436 | 436 |
437 #if !defined(DISABLE_NACL) | 437 #if !defined(DISABLE_NACL) |
438 class MediaGalleriesPlatformAppPpapiTest | 438 class MediaGalleriesPlatformAppPpapiTest |
439 : public MediaGalleriesPlatformAppBrowserTest { | 439 : public MediaGalleriesPlatformAppBrowserTest { |
440 protected: | 440 protected: |
441 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 441 virtual void SetUpCommandLine(CommandLine* command_line) override { |
442 MediaGalleriesPlatformAppBrowserTest::SetUpCommandLine(command_line); | 442 MediaGalleriesPlatformAppBrowserTest::SetUpCommandLine(command_line); |
443 command_line->AppendSwitch(switches::kEnablePepperTesting); | 443 command_line->AppendSwitch(switches::kEnablePepperTesting); |
444 } | 444 } |
445 | 445 |
446 virtual void SetUpOnMainThread() OVERRIDE { | 446 virtual void SetUpOnMainThread() override { |
447 MediaGalleriesPlatformAppBrowserTest::SetUpOnMainThread(); | 447 MediaGalleriesPlatformAppBrowserTest::SetUpOnMainThread(); |
448 | 448 |
449 ASSERT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA, &app_dir_)); | 449 ASSERT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA, &app_dir_)); |
450 app_dir_ = app_dir_.AppendASCII("ppapi") | 450 app_dir_ = app_dir_.AppendASCII("ppapi") |
451 .AppendASCII("tests") | 451 .AppendASCII("tests") |
452 .AppendASCII("extensions") | 452 .AppendASCII("extensions") |
453 .AppendASCII("media_galleries") | 453 .AppendASCII("media_galleries") |
454 .AppendASCII("newlib"); | 454 .AppendASCII("newlib"); |
455 } | 455 } |
456 | 456 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 | 669 |
670 base::ListValue custom_args; | 670 base::ListValue custom_args; |
671 #if defined(USE_PROPRIETARY_CODECS) | 671 #if defined(USE_PROPRIETARY_CODECS) |
672 custom_args.AppendBoolean(true); | 672 custom_args.AppendBoolean(true); |
673 #else | 673 #else |
674 custom_args.AppendBoolean(false); | 674 custom_args.AppendBoolean(false); |
675 #endif | 675 #endif |
676 ASSERT_TRUE(RunMediaGalleriesTestWithArg("media_metadata", custom_args)) | 676 ASSERT_TRUE(RunMediaGalleriesTestWithArg("media_metadata", custom_args)) |
677 << message_; | 677 << message_; |
678 } | 678 } |
OLD | NEW |