summaryrefslogtreecommitdiffstats
path: root/chrome/browser/importer/importer_unittest_utils.h
blob: a809c5a7b6b289f1b903c81ac9425b39b1296d4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) 2012 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.

#ifndef CHROME_BROWSER_IMPORTER_IMPORTER_UNITTEST_UTILS_H_
#define CHROME_BROWSER_IMPORTER_IMPORTER_UNITTEST_UTILS_H_

#include "base/message_loop.h"
#include "base/scoped_temp_dir.h"
#include "chrome/browser/importer/profile_writer.h"
#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace importer {
class ImporterProgressObserver;
}

class TestingProfile;

const int kMaxPathSize = 5;

struct BookmarkInfo {
  const bool in_toolbar;
  const size_t path_size;
  const wchar_t* path[kMaxPathSize];
  const wchar_t* title;
  const char* url;
};

// Returns true if the |entry| is equal to |expected|.
bool EqualBookmarkEntry(const ProfileWriter::BookmarkEntry& entry,
                        const BookmarkInfo& expected);

// Returns true if the |entry| is in the |list|.
bool FindBookmarkEntry(const ProfileWriter::BookmarkEntry& entry,
                       const BookmarkInfo* list,
                       int list_size);

// Test fixture class providing a message loop, ui/file thread,
// and a scoped temporary directory.
class ImporterTest : public testing::Test {
 public:
  ImporterTest();
  virtual ~ImporterTest();

 protected:
  virtual void SetUp() OVERRIDE;

  ScopedTempDir temp_dir_;
  scoped_ptr<TestingProfile> profile_;

 private:
  MessageLoopForUI message_loop_;
  content::TestBrowserThread ui_thread_;
  content::TestBrowserThread file_thread_;
};

#endif  // CHROME_BROWSER_IMPORTER_IMPORTER_UNITTEST_UTILS_H_