11320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Copyright 2014 The Chromium Authors. All rights reserved.
21320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Use of this source code is governed by a BSD-style license that can be
31320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// found in the LICENSE file.
41320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
51320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "base/compiler_specific.h"
61320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "base/macros.h"
71320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "base/memory/scoped_ptr.h"
81320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "base/message_loop/message_loop.h"
91320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "base/run_loop.h"
101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/component_updater/request_sender.h"
111320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/component_updater/test/test_configurator.h"
121320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/component_updater/test/url_request_post_interceptor.h"
131320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "net/url_request/url_fetcher.h"
141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "testing/gtest/include/gtest/gtest.h"
151320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
161320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinamespace component_updater {
171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
181320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinamespace {
191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
201320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciconst char kUrl1[] = "https://localhost2/path1";
211320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciconst char kUrl2[] = "https://localhost2/path2";
221320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciconst char kUrlPath1[] = "path1";
231320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciconst char kUrlPath2[] = "path2";
241320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
251320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}  // namespace
261320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
271320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass RequestSenderTest : public testing::Test {
281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci public:
291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  RequestSenderTest();
301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual ~RequestSenderTest();
311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Overrides from testing::Test.
331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual void SetUp() OVERRIDE;
341320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual void TearDown() OVERRIDE;
351320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
361320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  void RequestSenderComplete(const net::URLFetcher* source);
371320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
381320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci protected:
391320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  void Quit();
401320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  void RunThreads();
411320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  void RunThreadsUntilIdle();
421320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
431320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  scoped_ptr<TestConfigurator> config_;
441320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  scoped_ptr<RequestSender> request_sender_;
451320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  scoped_ptr<InterceptorFactory> interceptor_factory_;
461320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
471320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  URLRequestPostInterceptor* post_interceptor_1;  // Owned by the factory.
481320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  URLRequestPostInterceptor* post_interceptor_2;  // Owned by the factory.
491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  const net::URLFetcher* url_fetcher_source_;
511320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci private:
531320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  base::MessageLoopForIO loop_;
541320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  base::Closure quit_closure_;
551320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
561320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  DISALLOW_COPY_AND_ASSIGN(RequestSenderTest);
571320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci};
581320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
591320f92c476a1ad9d19dba2a48c72b75566198e9Primiano TucciRequestSenderTest::RequestSenderTest()
601320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    : post_interceptor_1(NULL),
611320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      post_interceptor_2(NULL),
621320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      url_fetcher_source_(NULL) {
631320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  net::URLFetcher::SetEnableInterceptionForTests(true);
641320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
651320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
661320f92c476a1ad9d19dba2a48c72b75566198e9Primiano TucciRequestSenderTest::~RequestSenderTest() {
671320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  net::URLFetcher::SetEnableInterceptionForTests(false);
681320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
701320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid RequestSenderTest::SetUp() {
711320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  config_.reset(new TestConfigurator(base::MessageLoopProxy::current(),
721320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                                     base::MessageLoopProxy::current()));
731320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  interceptor_factory_.reset(
741320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      new InterceptorFactory(base::MessageLoopProxy::current()));
751320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  post_interceptor_1 =
761320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      interceptor_factory_->CreateInterceptorForPath(kUrlPath1);
771320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  post_interceptor_2 =
781320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      interceptor_factory_->CreateInterceptorForPath(kUrlPath2);
791320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_TRUE(post_interceptor_1);
801320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_TRUE(post_interceptor_2);
811320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
821320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  request_sender_.reset();
831320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
841320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
851320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid RequestSenderTest::TearDown() {
861320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  request_sender_.reset();
871320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
881320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  post_interceptor_1 = NULL;
891320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  post_interceptor_2 = NULL;
901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
911320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  interceptor_factory_.reset();
921320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
931320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  config_.reset();
941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
951320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  RunThreadsUntilIdle();
961320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
971320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
981320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid RequestSenderTest::RunThreads() {
991320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  base::RunLoop runloop;
1001320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  quit_closure_ = runloop.QuitClosure();
1011320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  runloop.Run();
1021320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1031320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Since some tests need to drain currently enqueued tasks such as network
1041320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // intercepts on the IO thread, run the threads until they are
1051320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // idle. The component updater service won't loop again until the loop count
1061320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // is set and the service is started.
1071320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  RunThreadsUntilIdle();
1081320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
1091320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid RequestSenderTest::RunThreadsUntilIdle() {
1111320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  base::RunLoop().RunUntilIdle();
1121320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
1131320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid RequestSenderTest::Quit() {
1151320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  if (!quit_closure_.is_null())
1161320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    quit_closure_.Run();
1171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
1181320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid RequestSenderTest::RequestSenderComplete(const net::URLFetcher* source) {
1201320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  url_fetcher_source_ = source;
1211320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  Quit();
1221320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
1231320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1241320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Tests that when a request to the first url succeeds, the subsequent urls are
1251320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// not tried.
1261320f92c476a1ad9d19dba2a48c72b75566198e9Primiano TucciTEST_F(RequestSenderTest, RequestSendSuccess) {
1271320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_TRUE(post_interceptor_1->ExpectRequest(new PartialMatch("test")));
1281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  std::vector<GURL> urls;
1301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  urls.push_back(GURL(kUrl1));
1311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  urls.push_back(GURL(kUrl2));
1321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  request_sender_.reset(new RequestSender(*config_));
1331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  request_sender_->Send("test",
1341320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                        urls,
1351320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                        base::Bind(&RequestSenderTest::RequestSenderComplete,
1361320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                                   base::Unretained(this)));
1371320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  RunThreads();
1381320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1391320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_EQ(1, post_interceptor_1->GetHitCount())
1401320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      << post_interceptor_1->GetRequestsAsString();
1411320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_EQ(1, post_interceptor_1->GetCount())
1421320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      << post_interceptor_1->GetRequestsAsString();
1431320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1441320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_STREQ("test", post_interceptor_1->GetRequests()[0].c_str());
1451320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_EQ(GURL(kUrl1), url_fetcher_source_->GetOriginalURL());
1461320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_EQ(200, url_fetcher_source_->GetResponseCode());
1471320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
1481320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Tests that the request succeeds using the second url after the first url
1501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// has failed.
1511320f92c476a1ad9d19dba2a48c72b75566198e9Primiano TucciTEST_F(RequestSenderTest, RequestSendSuccessWithFallback) {
1521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_TRUE(post_interceptor_1->ExpectRequest(new PartialMatch("test"), 403));
1531320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_TRUE(post_interceptor_2->ExpectRequest(new PartialMatch("test")));
1541320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1551320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  std::vector<GURL> urls;
1561320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  urls.push_back(GURL(kUrl1));
1571320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  urls.push_back(GURL(kUrl2));
1581320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  request_sender_.reset(new RequestSender(*config_));
1591320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  request_sender_->Send("test",
1601320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                        urls,
1611320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                        base::Bind(&RequestSenderTest::RequestSenderComplete,
1621320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                                   base::Unretained(this)));
1631320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  RunThreads();
1641320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1651320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_EQ(1, post_interceptor_1->GetHitCount())
1661320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      << post_interceptor_1->GetRequestsAsString();
1671320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_EQ(1, post_interceptor_1->GetCount())
1681320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      << post_interceptor_1->GetRequestsAsString();
1691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_EQ(1, post_interceptor_2->GetHitCount())
1701320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      << post_interceptor_2->GetRequestsAsString();
1711320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_EQ(1, post_interceptor_2->GetCount())
1721320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      << post_interceptor_2->GetRequestsAsString();
1731320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1741320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_STREQ("test", post_interceptor_1->GetRequests()[0].c_str());
1751320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_STREQ("test", post_interceptor_2->GetRequests()[0].c_str());
1761320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_EQ(GURL(kUrl2), url_fetcher_source_->GetOriginalURL());
1771320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_EQ(200, url_fetcher_source_->GetResponseCode());
1781320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
1791320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1801320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Tests that the request fails when both urls have failed.
1811320f92c476a1ad9d19dba2a48c72b75566198e9Primiano TucciTEST_F(RequestSenderTest, RequestSendFailed) {
1821320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_TRUE(post_interceptor_1->ExpectRequest(new PartialMatch("test"), 403));
1831320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_TRUE(post_interceptor_2->ExpectRequest(new PartialMatch("test"), 403));
1841320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1851320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  std::vector<GURL> urls;
1861320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  urls.push_back(GURL(kUrl1));
1871320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  urls.push_back(GURL(kUrl2));
1881320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  request_sender_.reset(new RequestSender(*config_));
1891320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  request_sender_->Send("test",
1901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                        urls,
1911320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                        base::Bind(&RequestSenderTest::RequestSenderComplete,
1921320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                                   base::Unretained(this)));
1931320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  RunThreads();
1941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1951320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_EQ(1, post_interceptor_1->GetHitCount())
1961320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      << post_interceptor_1->GetRequestsAsString();
1971320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_EQ(1, post_interceptor_1->GetCount())
1981320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      << post_interceptor_1->GetRequestsAsString();
1991320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_EQ(1, post_interceptor_2->GetHitCount())
2001320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      << post_interceptor_2->GetRequestsAsString();
2011320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_EQ(1, post_interceptor_2->GetCount())
2021320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      << post_interceptor_2->GetRequestsAsString();
2031320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
2041320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_STREQ("test", post_interceptor_1->GetRequests()[0].c_str());
2051320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_STREQ("test", post_interceptor_2->GetRequests()[0].c_str());
2061320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_EQ(GURL(kUrl2), url_fetcher_source_->GetOriginalURL());
2071320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EXPECT_EQ(403, url_fetcher_source_->GetResponseCode());
2081320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
2091320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
2101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}  // namespace component_updater
211