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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 Manifest::TYPE_LEGACY_PACKAGED_APP, 1}}; | 93 Manifest::TYPE_LEGACY_PACKAGED_APP, 1}}; |
94 | 94 |
95 } // namespace | 95 } // namespace |
96 | 96 |
97 class WebstoreProviderTest : public InProcessBrowserTest { | 97 class WebstoreProviderTest : public InProcessBrowserTest { |
98 public: | 98 public: |
99 WebstoreProviderTest() {} | 99 WebstoreProviderTest() {} |
100 virtual ~WebstoreProviderTest() {} | 100 virtual ~WebstoreProviderTest() {} |
101 | 101 |
102 // InProcessBrowserTest overrides: | 102 // InProcessBrowserTest overrides: |
103 virtual void SetUpOnMainThread() override { | 103 void SetUpOnMainThread() override { |
104 test_server_.reset(new EmbeddedTestServer); | 104 test_server_.reset(new EmbeddedTestServer); |
105 | 105 |
106 ASSERT_TRUE(test_server_->InitializeAndWaitUntilReady()); | 106 ASSERT_TRUE(test_server_->InitializeAndWaitUntilReady()); |
107 test_server_->RegisterRequestHandler( | 107 test_server_->RegisterRequestHandler( |
108 base::Bind(&WebstoreProviderTest::HandleRequest, | 108 base::Bind(&WebstoreProviderTest::HandleRequest, |
109 base::Unretained(this))); | 109 base::Unretained(this))); |
110 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 110 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
111 switches::kAppsGalleryURL, test_server_->base_url().spec()); | 111 switches::kAppsGalleryURL, test_server_->base_url().spec()); |
112 CommandLine::ForCurrentProcess()->AppendSwitch( | 112 CommandLine::ForCurrentProcess()->AppendSwitch( |
113 switches::kEnableEphemeralApps); | 113 switches::kEnableEphemeralApps); |
114 | 114 |
115 webstore_provider_.reset(new WebstoreProvider( | 115 webstore_provider_.reset(new WebstoreProvider( |
116 ProfileManager::GetActiveUserProfile(), NULL)); | 116 ProfileManager::GetActiveUserProfile(), NULL)); |
117 webstore_provider_->set_webstore_search_fetched_callback( | 117 webstore_provider_->set_webstore_search_fetched_callback( |
118 base::Bind(&WebstoreProviderTest::OnSearchResultsFetched, | 118 base::Bind(&WebstoreProviderTest::OnSearchResultsFetched, |
119 base::Unretained(this))); | 119 base::Unretained(this))); |
120 // TODO(mukai): add test cases for throttling. | 120 // TODO(mukai): add test cases for throttling. |
121 webstore_provider_->set_use_throttling(false); | 121 webstore_provider_->set_use_throttling(false); |
122 } | 122 } |
123 | 123 |
124 virtual void TearDownOnMainThread() override { | 124 void TearDownOnMainThread() override { |
125 EXPECT_TRUE(test_server_->ShutdownAndWaitUntilComplete()); | 125 EXPECT_TRUE(test_server_->ShutdownAndWaitUntilComplete()); |
126 test_server_.reset(); | 126 test_server_.reset(); |
127 } | 127 } |
128 | 128 |
129 void RunQuery(const std::string& query, | 129 void RunQuery(const std::string& query, |
130 const std::string& mock_server_response) { | 130 const std::string& mock_server_response) { |
131 webstore_provider_->Start(base::UTF8ToUTF16(query)); | 131 webstore_provider_->Start(base::UTF8ToUTF16(query)); |
132 | 132 |
133 if (webstore_provider_->webstore_search_ && !mock_server_response.empty()) { | 133 if (webstore_provider_->webstore_search_ && !mock_server_response.empty()) { |
134 mock_server_response_ = mock_server_response; | 134 mock_server_response_ = mock_server_response; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 #endif | 300 #endif |
301 IN_PROC_BROWSER_TEST_F(WebstoreProviderTest, MAYBE_SearchCache) { | 301 IN_PROC_BROWSER_TEST_F(WebstoreProviderTest, MAYBE_SearchCache) { |
302 RunQueryAndVerify("foo", kOneResult, kParsedOneResult, 1); | 302 RunQueryAndVerify("foo", kOneResult, kParsedOneResult, 1); |
303 | 303 |
304 // No result is provided but the provider gets the result from the cache. | 304 // No result is provided but the provider gets the result from the cache. |
305 RunQueryAndVerify("foo", "", kParsedOneResult, 1); | 305 RunQueryAndVerify("foo", "", kParsedOneResult, 1); |
306 } | 306 } |
307 | 307 |
308 } // namespace test | 308 } // namespace test |
309 } // namespace app_list | 309 } // namespace app_list |
OLD | NEW |