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 // MediaGalleriesPrivate gallery watch API browser tests. | 5 // MediaGalleriesPrivate gallery watch API browser tests. |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "chrome/browser/extensions/extension_apitest.h" | 12 #include "chrome/browser/extensions/extension_apitest.h" |
13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
14 #include "chrome/browser/extensions/extension_test_message_listener.h" | 14 #include "chrome/browser/extensions/extension_test_message_listener.h" |
15 #include "chrome/browser/media_galleries/media_galleries_test_util.h" | 15 #include "chrome/browser/media_galleries/media_galleries_test_util.h" |
16 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
17 #include "chrome/common/chrome_switches.h" | |
18 #include "content/public/browser/render_frame_host.h" | 17 #include "content/public/browser/render_frame_host.h" |
19 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
20 #include "extensions/browser/extension_system.h" | 19 #include "extensions/browser/extension_system.h" |
21 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
| 21 #include "extensions/common/switches.h" |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 // Id of test extension from | 25 // Id of test extension from |
26 // chrome/test/data/extensions/api_test/|kTestExtensionPath| | 26 // chrome/test/data/extensions/api_test/|kTestExtensionPath| |
27 const char kTestExtensionId[] = "gceegfkgibmgpfopknlcgleimclbknie"; | 27 const char kTestExtensionId[] = "gceegfkgibmgpfopknlcgleimclbknie"; |
28 const char kTestExtensionPath[] = "media_galleries_private/gallerywatch"; | 28 const char kTestExtensionPath[] = "media_galleries_private/gallerywatch"; |
29 | 29 |
30 #if !defined(OS_CHROMEOS) | 30 #if !defined(OS_CHROMEOS) |
31 // JS commands. | 31 // JS commands. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 class MediaGalleriesPrivateGalleryWatchApiTest : public ExtensionApiTest { | 76 class MediaGalleriesPrivateGalleryWatchApiTest : public ExtensionApiTest { |
77 public: | 77 public: |
78 MediaGalleriesPrivateGalleryWatchApiTest() {} | 78 MediaGalleriesPrivateGalleryWatchApiTest() {} |
79 virtual ~MediaGalleriesPrivateGalleryWatchApiTest() {} | 79 virtual ~MediaGalleriesPrivateGalleryWatchApiTest() {} |
80 | 80 |
81 protected: | 81 protected: |
82 // ExtensionApiTest overrides. | 82 // ExtensionApiTest overrides. |
83 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 83 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
84 ExtensionApiTest::SetUpCommandLine(command_line); | 84 ExtensionApiTest::SetUpCommandLine(command_line); |
85 command_line->AppendSwitchASCII(switches::kWhitelistedExtensionID, | 85 command_line->AppendSwitchASCII( |
86 kTestExtensionId); | 86 extensions::switches::kWhitelistedExtensionID, |
| 87 kTestExtensionId); |
87 } | 88 } |
88 | 89 |
89 void ExecuteCmdAndCheckReply(content::RenderViewHost* host, | 90 void ExecuteCmdAndCheckReply(content::RenderViewHost* host, |
90 const std::string& js_command, | 91 const std::string& js_command, |
91 const std::string& ok_message) { | 92 const std::string& ok_message) { |
92 ExtensionTestMessageListener listener(ok_message, false); | 93 ExtensionTestMessageListener listener(ok_message, false); |
93 host->GetMainFrame()->ExecuteJavaScript(base::ASCIIToUTF16(js_command)); | 94 host->GetMainFrame()->ExecuteJavaScript(base::ASCIIToUTF16(js_command)); |
94 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 95 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
95 } | 96 } |
96 | 97 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 // Gallery watchers does not exists. | 427 // Gallery watchers does not exists. |
427 // chrome.mediaGalleriesPrivate.getAllGalleryWatch should return an empty | 428 // chrome.mediaGalleriesPrivate.getAllGalleryWatch should return an empty |
428 // list. | 429 // list. |
429 ExtensionTestMessageListener get_all_gallery_watch_finished( | 430 ExtensionTestMessageListener get_all_gallery_watch_finished( |
430 kGetAllGalleryWatchResultA, false /* no reply */); | 431 kGetAllGalleryWatchResultA, false /* no reply */); |
431 ExecuteCmdAndCheckReply(host, kGetAllWatchedGalleryIdsCmd, | 432 ExecuteCmdAndCheckReply(host, kGetAllWatchedGalleryIdsCmd, |
432 kGetAllGalleryWatchOK); | 433 kGetAllGalleryWatchOK); |
433 EXPECT_TRUE(get_all_gallery_watch_finished.WaitUntilSatisfied()); | 434 EXPECT_TRUE(get_all_gallery_watch_finished.WaitUntilSatisfied()); |
434 } | 435 } |
435 #endif | 436 #endif |
OLD | NEW |