// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/ref_counted.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/chromeos/cros/mock_update_library.h"
#include "chrome/browser/chromeos/update_observer.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/automation/dom_element_proxy.h"
#include "chrome/test/in_process_browser_test.h"
#include "chrome/test/ui_test_utils.h"

using ::testing::AnyNumber;
using ::testing::InvokeWithoutArgs;
using ::testing::Return;
using ::testing::ReturnRef;
using ::testing::_;
using ::testing::Invoke;
using ::testing::Exactly;

namespace {

typedef ObserverList<chromeos::UpdateLibrary::Observer> Observers;

void CallObservers(chromeos::MockUpdateLibrary* lib,
                   Observers* observers,
                   const chromeos::UpdateLibrary::Status& x) {
  EXPECT_CALL(*lib, status())
    .Times(AnyNumber())
    .WillRepeatedly((ReturnRef(x)))
    .RetiresOnSaturation();
  FOR_EACH_OBSERVER(chromeos::UpdateLibrary::Observer, *observers,
                    UpdateStatusChanged(lib));
}

void FireSuccessSequence(chromeos::MockUpdateLibrary* lib,
                         Observers* observer) {
  chromeos::UpdateLibrary::Status status;

  status.status = chromeos::UPDATE_STATUS_IDLE;
  CallObservers(lib, observer, status);

  status.status = chromeos::UPDATE_STATUS_CHECKING_FOR_UPDATE;
  CallObservers(lib, observer, status);

  status.status = chromeos::UPDATE_STATUS_UPDATE_AVAILABLE;
  CallObservers(lib, observer, status);

  status.status = chromeos::UPDATE_STATUS_DOWNLOADING;
  status.download_progress = 10;
  CallObservers(lib, observer, status);

  status.status = chromeos::UPDATE_STATUS_DOWNLOADING;
  status.download_progress = 50;
  CallObservers(lib, observer, status);

  status.status = chromeos::UPDATE_STATUS_DOWNLOADING;
  status.download_progress = 90;
  CallObservers(lib, observer, status);

  status.status = chromeos::UPDATE_STATUS_VERIFYING;
  CallObservers(lib, observer, status);

  status.status = chromeos::UPDATE_STATUS_FINALIZING;
  CallObservers(lib, observer, status);

  status.status = chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT;
  CallObservers(lib, observer, status);
}

void FireFailureSequence(chromeos::MockUpdateLibrary* lib,
                         Observers* observer) {
  chromeos::UpdateLibrary::Status status;

  status.status = chromeos::UPDATE_STATUS_IDLE;
  CallObservers(lib, observer, status);

  status.status = chromeos::UPDATE_STATUS_CHECKING_FOR_UPDATE;
  CallObservers(lib, observer, status);

  status.status = chromeos::UPDATE_STATUS_UPDATE_AVAILABLE;
  CallObservers(lib, observer, status);

  status.status = chromeos::UPDATE_STATUS_DOWNLOADING;
  status.download_progress = 10;
  CallObservers(lib, observer, status);

  status.status = chromeos::UPDATE_STATUS_ERROR;
  status.download_progress = 10;
  CallObservers(lib, observer, status);
}

class UpdateBrowserTest : public InProcessBrowserTest {
 public:
  UpdateBrowserTest() {}
};

IN_PROC_BROWSER_TEST_F(UpdateBrowserTest, Notifications) {
  scoped_ptr<chromeos::MockUpdateLibrary> lib(
      new chromeos::MockUpdateLibrary());

  Observers observers;

  EXPECT_CALL(*lib, AddObserver(_))
      .WillRepeatedly(Invoke(&observers,
                             &Observers::AddObserver));

  chromeos::UpdateObserver* observe =
      new chromeos::UpdateObserver(browser()->profile());
  lib->AddObserver(observe);

  FireSuccessSequence(lib.get(), &observers);
  FireFailureSequence(lib.get(), &observers);
}

}  // namespace

