OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 } // namespace | 47 } // namespace |
48 | 48 |
49 class DriveFirstRunTest : public InProcessBrowserTest, | 49 class DriveFirstRunTest : public InProcessBrowserTest, |
50 public DriveFirstRunController::Observer { | 50 public DriveFirstRunController::Observer { |
51 protected: | 51 protected: |
52 DriveFirstRunTest(); | 52 DriveFirstRunTest(); |
53 | 53 |
54 // InProcessBrowserTest overrides: | 54 // InProcessBrowserTest overrides: |
55 virtual void SetUpOnMainThread() OVERRIDE; | 55 virtual void SetUpOnMainThread() OVERRIDE; |
56 virtual void CleanUpOnMainThread() OVERRIDE; | 56 virtual void TearDownOnMainThread() OVERRIDE; |
57 | 57 |
58 // DriveFirstRunController::Observer overrides: | 58 // DriveFirstRunController::Observer overrides: |
59 virtual void OnCompletion(bool success) OVERRIDE; | 59 virtual void OnCompletion(bool success) OVERRIDE; |
60 virtual void OnTimedOut() OVERRIDE; | 60 virtual void OnTimedOut() OVERRIDE; |
61 | 61 |
62 void InstallApp(); | 62 void InstallApp(); |
63 | 63 |
64 void InitTestServer(const std::string& directory); | 64 void InitTestServer(const std::string& directory); |
65 | 65 |
66 bool WaitForFirstRunResult(); | 66 bool WaitForFirstRunResult(); |
(...skipping 28 matching lines...) Expand all Loading... |
95 | 95 |
96 host_resolver()->AddRule("example.com", "127.0.0.1"); | 96 host_resolver()->AddRule("example.com", "127.0.0.1"); |
97 | 97 |
98 // |controller_| will delete itself when it completes. | 98 // |controller_| will delete itself when it completes. |
99 controller_ = new DriveFirstRunController(browser()->profile()); | 99 controller_ = new DriveFirstRunController(browser()->profile()); |
100 controller_->AddObserver(this); | 100 controller_->AddObserver(this); |
101 controller_->SetDelaysForTest(0, 10); | 101 controller_->SetDelaysForTest(0, 10); |
102 controller_->SetAppInfoForTest(kTestAppId, kTestEndpointUrl); | 102 controller_->SetAppInfoForTest(kTestAppId, kTestEndpointUrl); |
103 } | 103 } |
104 | 104 |
105 void DriveFirstRunTest::CleanUpOnMainThread() { | 105 void DriveFirstRunTest::TearDownOnMainThread() { |
106 InProcessBrowserTest::CleanUpOnMainThread(); | |
107 content::RunAllPendingInMessageLoop(); | 106 content::RunAllPendingInMessageLoop(); |
108 } | 107 } |
109 | 108 |
110 void DriveFirstRunTest::InitTestServer(const std::string& directory) { | 109 void DriveFirstRunTest::InitTestServer(const std::string& directory) { |
111 embedded_test_server()->ServeFilesFromDirectory( | 110 embedded_test_server()->ServeFilesFromDirectory( |
112 test_data_dir_.AppendASCII(directory)); | 111 test_data_dir_.AppendASCII(directory)); |
113 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 112 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
114 | 113 |
115 // Configure the endpoint to use the test server's port. | 114 // Configure the endpoint to use the test server's port. |
116 const GURL url(kTestEndpointUrl); | 115 const GURL url(kTestEndpointUrl); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // Test that the controller times out instead of hanging forever. | 182 // Test that the controller times out instead of hanging forever. |
184 InstallApp(); | 183 InstallApp(); |
185 InitTestServer(kBadServerDirectory); | 184 InitTestServer(kBadServerDirectory); |
186 SetDelays(0, 0); | 185 SetDelays(0, 0); |
187 EnableOfflineMode(); | 186 EnableOfflineMode(); |
188 EXPECT_FALSE(WaitForFirstRunResult()); | 187 EXPECT_FALSE(WaitForFirstRunResult()); |
189 EXPECT_TRUE(timed_out()); | 188 EXPECT_TRUE(timed_out()); |
190 } | 189 } |
191 | 190 |
192 } // namespace chromeos | 191 } // namespace chromeos |
OLD | NEW |