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

Side by Side Diff: chrome/browser/notifications/platform_notification_service_browsertest.cc

Issue 1409163006: Migrating tests to use EmbeddedTestServer (/chrome/browser misc) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/notifications/desktop_notification_profile_util.h" 13 #include "chrome/browser/notifications/desktop_notification_profile_util.h"
14 #include "chrome/browser/notifications/notification_permission_context.h" 14 #include "chrome/browser/notifications/notification_permission_context.h"
15 #include "chrome/browser/notifications/notification_permission_context_factory.h " 15 #include "chrome/browser/notifications/notification_permission_context_factory.h "
16 #include "chrome/browser/notifications/notification_test_util.h" 16 #include "chrome/browser/notifications/notification_test_util.h"
17 #include "chrome/browser/notifications/platform_notification_service_impl.h" 17 #include "chrome/browser/notifications/platform_notification_service_impl.h"
18 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 19 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 20 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
22 #include "chrome/grit/generated_resources.h" 22 #include "chrome/grit/generated_resources.h"
23 #include "chrome/test/base/in_process_browser_test.h" 23 #include "chrome/test/base/in_process_browser_test.h"
24 #include "chrome/test/base/ui_test_utils.h" 24 #include "chrome/test/base/ui_test_utils.h"
25 #include "content/public/test/browser_test_utils.h" 25 #include "content/public/test/browser_test_utils.h"
26 #include "net/base/filename_util.h" 26 #include "net/base/filename_util.h"
27 #include "net/test/spawned_test_server/spawned_test_server.h" 27 #include "net/test/embedded_test_server/embedded_test_server.h"
28 #include "testing/gmock/include/gmock/gmock.h" 28 #include "testing/gmock/include/gmock/gmock.h"
29 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
30 30
31 // ----------------------------------------------------------------------------- 31 // -----------------------------------------------------------------------------
32 32
33 // Dimensions of the icon.png resource in the notification test data directory. 33 // Dimensions of the icon.png resource in the notification test data directory.
34 const int kIconWidth = 100; 34 const int kIconWidth = 100;
35 const int kIconHeight = 100; 35 const int kIconHeight = 100;
36 36
37 const int kNotificationVibrationPattern[] = { 100, 200, 300 }; 37 const int kNotificationVibrationPattern[] = { 100, 200, 300 };
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 std::string RequestAndRespondToPermission( 78 std::string RequestAndRespondToPermission(
79 PermissionBubbleManager::AutoResponseType bubble_response); 79 PermissionBubbleManager::AutoResponseType bubble_response);
80 80
81 content::WebContents* GetActiveWebContents(Browser* browser) { 81 content::WebContents* GetActiveWebContents(Browser* browser) {
82 return browser->tab_strip_model()->GetActiveWebContents(); 82 return browser->tab_strip_model()->GetActiveWebContents();
83 } 83 }
84 84
85 const base::FilePath server_root_; 85 const base::FilePath server_root_;
86 const std::string test_page_url_; 86 const std::string test_page_url_;
87 scoped_ptr<StubNotificationUIManager> ui_manager_; 87 scoped_ptr<StubNotificationUIManager> ui_manager_;
88 scoped_ptr<net::SpawnedTestServer> https_server_; 88 scoped_ptr<net::EmbeddedTestServer> https_server_;
89 }; 89 };
90 90
91 // ----------------------------------------------------------------------------- 91 // -----------------------------------------------------------------------------
92 92
93 namespace { 93 namespace {
94 const char kTestFileName[] = "notifications/platform_notification_service.html"; 94 const char kTestFileName[] = "notifications/platform_notification_service.html";
95 } 95 }
96 96
97 PlatformNotificationServiceBrowserTest::PlatformNotificationServiceBrowserTest() 97 PlatformNotificationServiceBrowserTest::PlatformNotificationServiceBrowserTest()
98 : server_root_(FILE_PATH_LITERAL("chrome/test/data")), 98 : server_root_(FILE_PATH_LITERAL("chrome/test/data")),
99 // The test server has a base directory that doesn't exist in the 99 // The test server has a base directory that doesn't exist in the
100 // filesystem. 100 // filesystem.
101 test_page_url_(std::string("files/") + kTestFileName) { 101 test_page_url_(std::string("/") + kTestFileName) {}
102 }
103 102
104 void PlatformNotificationServiceBrowserTest::SetUp() { 103 void PlatformNotificationServiceBrowserTest::SetUp() {
105 ui_manager_.reset(new StubNotificationUIManager); 104 ui_manager_.reset(new StubNotificationUIManager);
106 https_server_.reset(new net::SpawnedTestServer( 105 https_server_.reset(
107 net::SpawnedTestServer::TYPE_HTTPS, 106 new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS));
108 net::BaseTestServer::SSLOptions(net::BaseTestServer::SSLOptions::CERT_OK), 107 https_server_->ServeFilesFromSourceDirectory(server_root_);
109 server_root_));
110 ASSERT_TRUE(https_server_->Start()); 108 ASSERT_TRUE(https_server_->Start());
111 109
112 service()->SetNotificationUIManagerForTesting(ui_manager_.get()); 110 service()->SetNotificationUIManagerForTesting(ui_manager_.get());
113 111
114 InProcessBrowserTest::SetUp(); 112 InProcessBrowserTest::SetUp();
115 } 113 }
116 114
117 void PlatformNotificationServiceBrowserTest::SetUpOnMainThread() { 115 void PlatformNotificationServiceBrowserTest::SetUpOnMainThread() {
118 NavigateToTestPage(test_page_url_); 116 NavigateToTestPage(test_page_url_);
119 117
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 410
413 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); 411 ASSERT_EQ(1u, ui_manager()->GetNotificationCount());
414 412
415 const Notification& notification = ui_manager()->GetNotificationAt(0); 413 const Notification& notification = ui_manager()->GetNotificationAt(0);
416 EXPECT_FALSE(notification.icon().IsEmpty()); 414 EXPECT_FALSE(notification.icon().IsEmpty());
417 415
418 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title())); 416 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title()));
419 EXPECT_EQ(kIconWidth, notification.icon().Width()); 417 EXPECT_EQ(kIconWidth, notification.icon().Width());
420 EXPECT_EQ(kIconHeight, notification.icon().Height()); 418 EXPECT_EQ(kIconHeight, notification.icon().Height());
421 } 419 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698