| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/image_decoder.h" | 5 #include "chrome/browser/image_decoder.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/grit/generated_resources.h" | 9 #include "chrome/grit/generated_resources.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 test_request.reset(); | 236 test_request.reset(); |
| 237 runner->Run(); | 237 runner->Run(); |
| 238 } | 238 } |
| 239 | 239 |
| 240 // Killing the utility process counts as a crash. Thus the request fails. | 240 // Killing the utility process counts as a crash. Thus the request fails. |
| 241 // If ImageDecoder did not handle the crash properly, the request never finishes | 241 // If ImageDecoder did not handle the crash properly, the request never finishes |
| 242 // and this test would hang. | 242 // and this test would hang. |
| 243 // Note: This test is inherently racy because KillProcessObserver lives on the | 243 // Note: This test is inherently racy because KillProcessObserver lives on the |
| 244 // UI thread but ImageDecoder does its work mainly on the IO thread. So the test | 244 // UI thread but ImageDecoder does its work mainly on the IO thread. So the test |
| 245 // checks for both possible valid outcomes. | 245 // checks for both possible valid outcomes. |
| 246 IN_PROC_BROWSER_TEST_F(ImageDecoderBrowserTest, StartAndKillProcess) { | 246 // |
| 247 // Flaky timeouts on Linux ASan / LSan. crbug.com/618206 |
| 248 #if (defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER)) && defined(OS_LINUX) |
| 249 #define MAYBE_StartAndKillProcess DISABLED_StartAndKillProcess |
| 250 #else |
| 251 #define MAYBE_StartAndKillProcess StartAndKillProcess |
| 252 #endif |
| 253 IN_PROC_BROWSER_TEST_F(ImageDecoderBrowserTest, MAYBE_StartAndKillProcess) { |
| 247 KillProcessObserver observer; | 254 KillProcessObserver observer; |
| 248 scoped_refptr<content::MessageLoopRunner> runner = | 255 scoped_refptr<content::MessageLoopRunner> runner = |
| 249 new content::MessageLoopRunner; | 256 new content::MessageLoopRunner; |
| 250 TestImageRequest test_request(runner->QuitClosure()); | 257 TestImageRequest test_request(runner->QuitClosure()); |
| 251 ImageDecoder::Start(&test_request, GetValidPngString()); | 258 ImageDecoder::Start(&test_request, GetValidPngString()); |
| 252 runner->Run(); | 259 runner->Run(); |
| 253 if (!test_request.decode_succeeded()) { | 260 if (!test_request.decode_succeeded()) { |
| 254 // The UI thread won the race. Make sure the utility process did get killed. | 261 // The UI thread won the race. Make sure the utility process did get killed. |
| 255 EXPECT_TRUE(observer.did_kill()); | 262 EXPECT_TRUE(observer.did_kill()); |
| 256 } | 263 } |
| 257 // Else the IO thread won the race and the image got decoded. Oh well. | 264 // Else the IO thread won the race and the image got decoded. Oh well. |
| 258 } | 265 } |
| OLD | NEW |