Skip to content

Commit

Permalink
Merge pull request #881 from mozilla/create-nodetypes
Browse files Browse the repository at this point in the history
Fix createBookmarkItem in android places. Fixes #880
  • Loading branch information
thomcc committed Mar 29, 2019
2 parents 7452d4b + f5a4520 commit a16f7dc
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,13 @@

[Full Changelog](https://github.com/mozilla/application-services/compare/v0.22.1...master)

## Places

### What's Fixed

- createBookmarkItem on android will now create the correct type of bookmark.
([#880](https://github.com/mozilla/application-services/issues/880))

## Push

### Breaking changes
Expand Down
Expand Up @@ -408,7 +408,7 @@ class PlacesWriterConnection internal constructor(connHandle: Long, api: PlacesA

override fun createBookmarkItem(parentGUID: String, url: String, title: String, position: Int?): String {
val builder = MsgTypes.BookmarkNode.newBuilder()
.setNodeType(BookmarkType.Separator.value)
.setNodeType(BookmarkType.Bookmark.value)
.setParentGuid(parentGUID)
.setUrl(url)
.setTitle(title)
Expand Down
Expand Up @@ -178,4 +178,40 @@ class PlacesConnectionTest {
assert(infos[0].url == "https://www.example.com/2")
assert(infos[1].url == "https://www.example.com/3")
}

@Test
fun testCreateBookmark() {
val itemGUID = db.createBookmarkItem(
parentGUID = BookmarkRoot.Unfiled.id,
url = "https://www.example.com/",
title = "example")

val sepGUID = db.createSeparator(
parentGUID = BookmarkRoot.Unfiled.id,
position = 0)

val folderGUID = db.createFolder(
parentGUID = BookmarkRoot.Unfiled.id,
title = "example folder")

val item = db.getBookmark(itemGUID)!! as BookmarkItem
val sep = db.getBookmark(sepGUID)!! as BookmarkSeparator
val folder = db.getBookmark(folderGUID)!! as BookmarkFolder

assertEquals(item.type, BookmarkType.Bookmark)
assertEquals(sep.type, BookmarkType.Separator)
assertEquals(folder.type, BookmarkType.Folder)

assertEquals(item.title, "example")
assertEquals(item.url, "https://www.example.com/")
assertEquals(item.position, 1)
assertEquals(item.parentGUID, BookmarkRoot.Unfiled.id)

assertEquals(sep.position, 0)
assertEquals(sep.parentGUID, BookmarkRoot.Unfiled.id)

assertEquals(folder.title, "example folder")
assertEquals(folder.position, 2)
assertEquals(folder.parentGUID, BookmarkRoot.Unfiled.id)
}
}

0 comments on commit a16f7dc

Please sign in to comment.