OLD | NEW |
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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/memory/ref_counted.h" |
8 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
10 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
11 #include "chrome/browser/net/url_request_mock_util.h" | 12 #include "chrome/browser/net/url_request_mock_util.h" |
12 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
14 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/render_messages.h" | 16 #include "chrome/common/render_messages.h" |
16 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
17 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
19 #include "content/public/common/content_paths.h" | 20 #include "content/public/common/content_paths.h" |
20 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
21 #include "content/public/test/browser_test_utils.h" | 22 #include "content/public/test/browser_test_utils.h" |
22 #include "content/public/test/test_utils.h" | 23 #include "content/public/test/test_utils.h" |
23 #include "content/test/net/url_request_mock_http_job.h" | 24 #include "net/test/url_request/url_request_mock_http_job.h" |
24 #include "url/gurl.h" | 25 #include "url/gurl.h" |
25 | 26 |
26 using content::BrowserThread; | 27 using content::BrowserThread; |
27 using content::URLRequestMockHTTPJob; | 28 using net::URLRequestMockHTTPJob; |
28 | |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 // Tests that the NPAPI unauthorized plugin infobar is: | 32 // Tests that the NPAPI unauthorized plugin infobar is: |
33 // (1) Shown when the Finch trial is set to "Enabled" | 33 // (1) Shown when the Finch trial is set to "Enabled" |
34 // (2) Not shown when the Finch trial is set to "Disabled" | 34 // (2) Not shown when the Finch trial is set to "Disabled" |
35 // TODO(cthomp): Remove/simplify when Finch trial is completed crbug.com/381944 | 35 // TODO(cthomp): Remove/simplify when Finch trial is completed crbug.com/381944 |
36 class UnauthorizedPluginInfoBarBrowserTest : public InProcessBrowserTest { | 36 class UnauthorizedPluginInfoBarBrowserTest : public InProcessBrowserTest { |
37 protected: | 37 protected: |
38 UnauthorizedPluginInfoBarBrowserTest() {} | 38 UnauthorizedPluginInfoBarBrowserTest() {} |
39 | 39 |
40 // Makes URLRequestMockHTTPJobs serve data from content::DIR_TEST_DATA | 40 // Makes URLRequestMockHTTPJobs serve data from content::DIR_TEST_DATA |
41 // instead of chrome::DIR_TEST_DATA. | 41 // instead of chrome::DIR_TEST_DATA. |
42 void ServeContentTestData() { | 42 void ServeContentTestData() { |
43 base::FilePath root_http; | 43 base::FilePath root_http; |
44 PathService::Get(content::DIR_TEST_DATA, &root_http); | 44 PathService::Get(content::DIR_TEST_DATA, &root_http); |
45 scoped_refptr<content::MessageLoopRunner> runner = | 45 scoped_refptr<content::MessageLoopRunner> runner = |
46 new content::MessageLoopRunner; | 46 new content::MessageLoopRunner; |
47 BrowserThread::PostTaskAndReply( | 47 BrowserThread::PostTaskAndReply( |
48 BrowserThread::IO, FROM_HERE, | 48 BrowserThread::IO, |
49 base::Bind(URLRequestMockHTTPJob::AddUrlHandler, root_http), | 49 FROM_HERE, |
| 50 base::Bind(URLRequestMockHTTPJob::AddUrlHandler, |
| 51 root_http, |
| 52 make_scoped_refptr(BrowserThread::GetBlockingPool())), |
50 runner->QuitClosure()); | 53 runner->QuitClosure()); |
51 runner->Run(); | 54 runner->Run(); |
52 } | 55 } |
53 | 56 |
54 public: | 57 public: |
55 // Verifies that the test page exists (only present with src-internal) | 58 // Verifies that the test page exists (only present with src-internal) |
56 bool TestPageExists() { | 59 bool TestPageExists() { |
57 return base::PathExists(ui_test_utils::GetTestFilePath( | 60 return base::PathExists(ui_test_utils::GetTestFilePath( |
58 base::FilePath(FILE_PATH_LITERAL("plugin")), | 61 base::FilePath(FILE_PATH_LITERAL("plugin")), |
59 base::FilePath(FILE_PATH_LITERAL("quicktime.html")))); | 62 base::FilePath(FILE_PATH_LITERAL("quicktime.html")))); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 return; | 106 return; |
104 } | 107 } |
105 base::FieldTrialList::CreateTrialsFromString( | 108 base::FieldTrialList::CreateTrialsFromString( |
106 "UnauthorizedPluginInfoBar/Disabled/", | 109 "UnauthorizedPluginInfoBar/Disabled/", |
107 base::FieldTrialList::ACTIVATE_TRIALS, | 110 base::FieldTrialList::ACTIVATE_TRIALS, |
108 std::set<std::string>()); | 111 std::set<std::string>()); |
109 InfoBarCountTest(0u, browser()); | 112 InfoBarCountTest(0u, browser()); |
110 } | 113 } |
111 | 114 |
112 } // namespace | 115 } // namespace |
OLD | NEW |