Welcome to mirror list, hosted at ThFree Co, Russian Federation.

kmz_unarchive_test.cpp « map_tests « map - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 07cdf70be078f7b53d556183e695b9cd1eeae626 (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
59
60
61
62
#include "testing/testing.hpp"

#include "map/framework.hpp"

#include "platform/platform.hpp"

#include "coding/zip_reader.hpp"

#include "base/scope_guard.hpp"

#include "std/string.hpp"
#include "std/vector.hpp"
#include "std/iostream.hpp"


UNIT_TEST(KMZ_UnzipTest)
{
  string const kmzFile = GetPlatform().TestsDataPathForFile("test.kmz");
  ZipFileReader::FileListT files;
  ZipFileReader::FilesList(kmzFile, files);

  bool isKMLinZip = false;

  for (int i = 0; i < files.size();++i)
  {
    if (files[i].first == "doc.kml")
    {
      isKMLinZip = true;
      break;
    }
  }
  TEST(isKMLinZip, ("No KML file in KMZ"));

  string const kmlFile = GetPlatform().WritablePathForFile("newKml.kml");
  MY_SCOPE_GUARD(fileGuard, bind(&FileWriter::DeleteFileX, kmlFile));
  ZipFileReader::UnzipFile(kmzFile, "doc.kml", kmlFile);

  Framework framework;
  BookmarkCategory cat("Default", framework);
  TEST(cat.LoadFromKML(new FileReader(kmlFile)), ());

  TEST_EQUAL(files.size(), 6, ("KMZ file wrong number of files"));

  TEST_EQUAL(cat.GetBookmarksCount(), 6, ("Category wrong number of bookmarks"));

  {
    Bookmark const * bm = cat.GetBookmark(5);
    TEST_EQUAL(bm->GetName(), ("Lahaina Breakwall"), ("KML wrong name!"));
    TEST_EQUAL(bm->GetType(), "placemark-red", ("KML wrong type!"));
    TEST_ALMOST_EQUAL_ULPS(bm->GetOrg().x, -156.6777046791284, ("KML wrong org x!"));
    TEST_ALMOST_EQUAL_ULPS(bm->GetOrg().y, 21.34256685860084, ("KML wrong org y!"));
    TEST_EQUAL(bm->GetScale(), -1, ("KML wrong scale!"));
  }
  {
    Bookmark const * bm = cat.GetBookmark(4);
    TEST_EQUAL(bm->GetName(), ("Seven Sacred Pools, Kipahulu"), ("KML wrong name!"));
    TEST_EQUAL(bm->GetType(), "placemark-red", ("KML wrong type!"));
    TEST_ALMOST_EQUAL_ULPS(bm->GetOrg().x, -156.0405130750025, ("KML wrong org x!"));
    TEST_ALMOST_EQUAL_ULPS(bm->GetOrg().y, 21.12480639056074, ("KML wrong org y!"));
    TEST_EQUAL(bm->GetScale(), -1, ("KML wrong scale!"));
  }
}