| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/files/file_util.h" | 5 #include "base/files/file_util.h" |
| 6 #include "base/memory/ptr_util.h" | 6 #include "base/memory/ptr_util.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "chrome/test/base/in_process_browser_test.h" | 8 #include "chrome/test/base/in_process_browser_test.h" |
| 9 #include "components/quirks/quirks_manager.h" | 9 #include "components/quirks/quirks_manager.h" |
| 10 #include "content/public/test/test_utils.h" | 10 #include "content/public/test/test_utils.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 void TestQuirksClient(int64_t product_id, bool find_fake_file) { | 58 void TestQuirksClient(int64_t product_id, bool find_fake_file) { |
| 59 // Set up fake url getter. | 59 // Set up fake url getter. |
| 60 QuirksManager::Get()->SetFakeQuirksFetcherCreatorForTests( | 60 QuirksManager::Get()->SetFakeQuirksFetcherCreatorForTests( |
| 61 base::Bind(find_fake_file ? &CreateFakeURLFetcherSuccess | 61 base::Bind(find_fake_file ? &CreateFakeURLFetcherSuccess |
| 62 : &CreateFakeURLFetcherFailure)); | 62 : &CreateFakeURLFetcherFailure)); |
| 63 | 63 |
| 64 base::RunLoop run_loop; | 64 base::RunLoop run_loop; |
| 65 end_message_loop_ = run_loop.QuitClosure(); | 65 end_message_loop_ = run_loop.QuitClosure(); |
| 66 | 66 |
| 67 quirks::QuirksManager::Get()->RequestIccProfilePath( | 67 quirks::QuirksManager::Get()->RequestIccProfilePath( |
| 68 product_id, base::Bind(&QuirksBrowserTest::OnQuirksClientFinished, | 68 product_id, std::string(), |
| 69 base::Unretained(this))); | 69 base::Bind(&QuirksBrowserTest::OnQuirksClientFinished, |
| 70 base::Unretained(this))); |
| 70 | 71 |
| 71 run_loop.Run(); | 72 run_loop.Run(); |
| 72 } | 73 } |
| 73 | 74 |
| 74 // Callback from RequestIccProfilePath(). | 75 // Callback from RequestIccProfilePath(). |
| 75 void OnQuirksClientFinished(const base::FilePath& path, bool downloaded) { | 76 void OnQuirksClientFinished(const base::FilePath& path, bool downloaded) { |
| 76 icc_path_ = path; | 77 icc_path_ = path; |
| 77 file_existed_ = !downloaded; | 78 file_existed_ = !downloaded; |
| 78 ASSERT_TRUE(!end_message_loop_.is_null()); | 79 ASSERT_TRUE(!end_message_loop_.is_null()); |
| 79 end_message_loop_.Run(); | 80 end_message_loop_.Run(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 EXPECT_EQ(file_existed_, true); | 121 EXPECT_EQ(file_existed_, true); |
| 121 | 122 |
| 122 // Finally, request a file that doesn't exist on fake Quirks Server. | 123 // Finally, request a file that doesn't exist on fake Quirks Server. |
| 123 TestQuirksClient(0x1111bbbb, false); | 124 TestQuirksClient(0x1111bbbb, false); |
| 124 EXPECT_EQ(icc_path_, base::FilePath()); | 125 EXPECT_EQ(icc_path_, base::FilePath()); |
| 125 EXPECT_EQ(file_existed_, false); | 126 EXPECT_EQ(file_existed_, false); |
| 126 EXPECT_FALSE(base::PathExists(GetPathForIccFile(0x1111bbbb))); | 127 EXPECT_FALSE(base::PathExists(GetPathForIccFile(0x1111bbbb))); |
| 127 } | 128 } |
| 128 | 129 |
| 129 } // namespace quirks | 130 } // namespace quirks |
| OLD | NEW |