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

Side by Side Diff: chrome/browser/chromeos/display/quirks_browsertest.cc

Issue 2431853002: Remove built-in path check from Quirks (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
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 22 matching lines...) Expand all
33 const GURL& url, 33 const GURL& url,
34 net::URLFetcherDelegate* delegate) { 34 net::URLFetcherDelegate* delegate) {
35 net::URLFetcher* fetcher = new net::FakeURLFetcher( 35 net::URLFetcher* fetcher = new net::FakeURLFetcher(
36 url, delegate, "File not found", net::HTTP_NOT_FOUND, 36 url, delegate, "File not found", net::HTTP_NOT_FOUND,
37 net::URLRequestStatus::FAILED); 37 net::URLRequestStatus::FAILED);
38 return base::WrapUnique(fetcher); 38 return base::WrapUnique(fetcher);
39 } 39 }
40 40
41 // Full path to fake icc file in <tmp test directory>/display_profiles/. 41 // Full path to fake icc file in <tmp test directory>/display_profiles/.
42 base::FilePath GetPathForIccFile(int64_t product_id) { 42 base::FilePath GetPathForIccFile(int64_t product_id) {
43 return QuirksManager::Get() 43 return QuirksManager::Get()->delegate()->GetDisplayProfileDirectory().Append(
44 ->delegate() 44 quirks::IdToFileName(product_id));
45 ->GetDownloadDisplayProfileDirectory()
46 .Append(quirks::IdToFileName(product_id));
47 } 45 }
48 46
49 } // namespace 47 } // namespace
50 48
51 class QuirksBrowserTest : public InProcessBrowserTest { 49 class QuirksBrowserTest : public InProcessBrowserTest {
52 public: 50 public:
53 QuirksBrowserTest() : file_existed_(false) {} 51 QuirksBrowserTest() : file_existed_(false) {}
54 52
55 protected: 53 protected:
56 ~QuirksBrowserTest() override = default; 54 ~QuirksBrowserTest() override = default;
(...skipping 23 matching lines...) Expand all
80 ASSERT_TRUE(!end_message_loop_.is_null()); 78 ASSERT_TRUE(!end_message_loop_.is_null());
81 end_message_loop_.Run(); 79 end_message_loop_.Run();
82 } 80 }
83 81
84 void SetUpOnMainThread() override { 82 void SetUpOnMainThread() override {
85 // NOTE: QuirksManager::Initialize() isn't necessary here, since it'll be 83 // NOTE: QuirksManager::Initialize() isn't necessary here, since it'll be
86 // called in ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun(). 84 // called in ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun().
87 85
88 // Create display_profiles subdirectory under temp profile directory. 86 // Create display_profiles subdirectory under temp profile directory.
89 const base::FilePath path = 87 const base::FilePath path =
90 QuirksManager::Get()->delegate()->GetDownloadDisplayProfileDirectory(); 88 QuirksManager::Get()->delegate()->GetDisplayProfileDirectory();
91 base::File::Error error = base::File::FILE_OK; 89 base::File::Error error = base::File::FILE_OK;
92 bool created = base::CreateDirectoryAndGetError(path, &error); 90 bool created = base::CreateDirectoryAndGetError(path, &error);
93 ASSERT_TRUE(created); 91 ASSERT_TRUE(created);
94 92
95 // Quirks clients can't run until after login. 93 // Quirks clients can't run until after login.
96 quirks::QuirksManager::Get()->OnLoginCompleted(); 94 quirks::QuirksManager::Get()->OnLoginCompleted();
97 } 95 }
98 96
99 base::Closure end_message_loop_; // Callback to terminate message loop. 97 base::Closure end_message_loop_; // Callback to terminate message loop.
100 base::FilePath icc_path_; // Path to icc file if found or downloaded. 98 base::FilePath icc_path_; // Path to icc file if found or downloaded.
(...skipping 21 matching lines...) Expand all
122 EXPECT_EQ(file_existed_, true); 120 EXPECT_EQ(file_existed_, true);
123 121
124 // Finally, request a file that doesn't exist on fake Quirks Server. 122 // Finally, request a file that doesn't exist on fake Quirks Server.
125 TestQuirksClient(0x1111bbbb, false); 123 TestQuirksClient(0x1111bbbb, false);
126 EXPECT_EQ(icc_path_, base::FilePath()); 124 EXPECT_EQ(icc_path_, base::FilePath());
127 EXPECT_EQ(file_existed_, false); 125 EXPECT_EQ(file_existed_, false);
128 EXPECT_FALSE(base::PathExists(GetPathForIccFile(0x1111bbbb))); 126 EXPECT_FALSE(base::PathExists(GetPathForIccFile(0x1111bbbb)));
129 } 127 }
130 128
131 } // namespace quirks 129 } // namespace quirks
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698