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

Side by Side Diff: chrome/browser/extensions/api/streams_private/streams_private_apitest.cc

Issue 281513003: Implement chrome.streamsPrivate.abort() extensions function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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) 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/download/download_prefs.h" 8 #include "chrome/browser/download/download_prefs.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 94 }
95 95
96 // A random HTML file to navigate to. 96 // A random HTML file to navigate to.
97 if (request.relative_url == "/index.html") { 97 if (request.relative_url == "/index.html") {
98 response->set_code(net::HTTP_OK); 98 response->set_code(net::HTTP_OK);
99 response->set_content("html content"); 99 response->set_content("html content");
100 response->set_content_type("text/html"); 100 response->set_content_type("text/html");
101 return response.PassAs<HttpResponse>(); 101 return response.PassAs<HttpResponse>();
102 } 102 }
103 103
104 // RTF files for testing chrome.streamsPrivate.abort().
105 if (request.relative_url == "/abort.rtf" ||
106 request.relative_url == "/no_abort.rtf") {
107 response->set_code(net::HTTP_OK);
108 response->set_content_type("application/rtf");
109 return response.PassAs<HttpResponse>();
110 }
111
104 // Respond to /favicon.ico for navigating to the page. 112 // Respond to /favicon.ico for navigating to the page.
105 if (request.relative_url == "/favicon.ico") { 113 if (request.relative_url == "/favicon.ico") {
106 response->set_code(net::HTTP_NOT_FOUND); 114 response->set_code(net::HTTP_NOT_FOUND);
107 return response.PassAs<HttpResponse>(); 115 return response.PassAs<HttpResponse>();
108 } 116 }
109 117
110 // No other requests should be handled in the tests. 118 // No other requests should be handled in the tests.
111 EXPECT_TRUE(false) << "NOTREACHED!"; 119 EXPECT_TRUE(false) << "NOTREACHED!";
112 response->set_code(net::HTTP_NOT_FOUND); 120 response->set_code(net::HTTP_NOT_FOUND);
113 return response.PassAs<HttpResponse>(); 121 return response.PassAs<HttpResponse>();
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 DownloadManager* download_manager = GetDownloadManager(); 422 DownloadManager* download_manager = GetDownloadManager();
415 std::vector<DownloadItem*> downloads; 423 std::vector<DownloadItem*> downloads;
416 download_manager->GetAllDownloads(&downloads); 424 download_manager->GetAllDownloads(&downloads);
417 ASSERT_EQ(0u, downloads.size()); 425 ASSERT_EQ(0u, downloads.size());
418 426
419 // The test extension should receive onExecuteContentHandler event with MIME 427 // The test extension should receive onExecuteContentHandler event with MIME
420 // type 'application/msexcel' (and call chrome.test.notifySuccess). 428 // type 'application/msexcel' (and call chrome.test.notifySuccess).
421 EXPECT_TRUE(catcher.GetNextResult()); 429 EXPECT_TRUE(catcher.GetNextResult());
422 } 430 }
423 431
432 // Tests that chrome.streamsPrivate.abort() works correctly.
433 IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, Abort) {
434 #if defined(OS_WIN) && defined(USE_ASH)
435 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
436 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
437 return;
438 #endif
439
440 ASSERT_TRUE(LoadTestExtension()) << message_;
441
442 ResultCatcher catcher;
443 ui_test_utils::NavigateToURL(browser(),
444 test_server_->GetURL("/no_abort.rtf"));
445 base::MessageLoop::current()->RunUntilIdle();
446 EXPECT_TRUE(catcher.GetNextResult());
447
448 ui_test_utils::NavigateToURL(browser(),
449 test_server_->GetURL("/abort.rtf"));
450 base::MessageLoop::current()->RunUntilIdle();
451 EXPECT_TRUE(catcher.GetNextResult());
452 }
453
424 } // namespace 454 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698